Solved

Graphics in MFC Dialog Box

Posted on 1998-08-09
3
558 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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
warmcat earned 100 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to programmatically differentiate between C and Java 10 196
Grammars for C C++ and java 1 122
Dynamically allocate memory 9 58
Error C2678: binary '!=': no operator found... 4 48
  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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

773 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