?
Solved

Graphics in MFC Dialog Box

Posted on 1998-08-09
3
Medium Priority
?
575 Views
Last Modified: 2008-02-01
I need to draw a graph like graphic item in a Dialog Box (MFC) which is changed during the execution of the program. How do I do this? Is the graphic item placed as a View item?
0
Comment
Question by:RM33
[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
3 Comments
 
LVL 2

Accepted Solution

by:
warmcat earned 400 total points
ID: 1169773
Place a 'picture control' (it's a little landscape on the Developer Studio control palette) on the dialog, and change the properties to Type: Frame, Color: Black.  Change the ID to something like IDC_STATIC_MYGRAPH.

Hit Ctrl-W to bring up the Classwizard for your dialog, and override WM_PAINT.

In the new CMyDialog::OnPaint(), you can use the following code to discover the bounding rectangle of the frame control, in dialog window coordinates:

      RECT rectDest, rectParent;
      CWnd *pwnd=GetDlgItem(IDC_STATIC_MYGRAPH);

      if(pwnd) {
            
            pwnd->GetWindowRect(&rectDest);
            GetWindowRect(&rectParent);
            rectDest.left-=rectParent.left;
            rectDest.right-=rectParent.left;
            rectDest.top-=rectParent.top;
            rectDest.bottom-=rectParent.top;

                ... draw in rectDest area only ...

          }

Any questions, mail me at andy@warmcat.com
0
 

Expert Comment

by:kraphics
ID: 1169774
This code may get the handle of the control, but code is also needed to paint or draw the image into the control.
I need to put a hdib into the control.
0
 
LVL 2

Expert Comment

by:warmcat
ID: 1169775
kraph, download http://warmcat.com/cdib.zip

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.

Question has a verified solution.

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

  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 …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

771 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