Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Plotting...

Me again...
I have a MFC dialog based application. It has a button on it. When I press the button, another dialog box opens. I want to place the x-y axes on this dialog and do plotting of variables that will be read by the program (real time plotting). Sunj gave me a push in the right direction but I am lost again. I decided to see what happens if I do the following. In the OnInitDialog of this second box I have placed the code...

CClientDC* pDC;
pDC = new CClientDC(this);
pDC->TextOut(50,50,"Hello",50)
pDC->LineTo(50,50)

And nothing happened... what am I doing wrong?
Thanks
0
rose3377
Asked:
rose3377
  • 2
  • 2
1 Solution
 
nietodCommented:
The dialog window has not been displayed at the time of OnInitDialog.  The DC you create will have no display area, so the text is not displayed.
0
 
Answers2000Commented:
>> what am I doing wrong?
1. CClientDC * is never deleted

2. In WM_INITDIALOG the dialog is not yet visible.  When it does become visible, WM_PAINT handles painting and will overwrite anything you have painted.

3. In life time of a dialog WM_PAINT may be called many times


TO FIX:
1. Override WM_PAINT
2. Make sure base classs etc.. are called so dialog is still painted.  
3. After the call to base class - add

ClientDC cdc(this);
cdc.TextOut(50,50,"Hello",50) ;
cdc.LineTo(50,50)  ;



0
 
nietodCommented:
Displaying should occur in the onPaint() member procedure.  However, a dialog will take care of displaying itself (if you let it, and you probably should let it do so.)  If you want to display "custom" images on a dialog, create a control (window) on the dialog of your own class and display your images in it on the onPaint() procedure.  Or don't use a dialog and create your own window class and display the image in the client area of the window your create.
0
 
Answers2000Commented:
>> a dialog will take care of displaying itself
It will, but you can add your own additional painting too.  Check Petzold book for an SDK style sample
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now