Solved

Plotting...

Posted on 1998-09-29
4
319 Views
Last Modified: 2010-04-01
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
Comment
Question by:rose3377
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 0 total points
ID: 1173978
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1173979
>> 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
 
LVL 22

Expert Comment

by:nietod
ID: 1173980
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1173981
>> 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question