Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Plotting...

Posted on 1998-09-29
4
Medium Priority
?
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

660 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