Solved

Plotting...

Posted on 1998-09-29
4
317 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
Comment Utility
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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
>> 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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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++.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now