[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Graphics in MFC Dialog Box

Posted on 1998-08-09
3
Medium Priority
?
587 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’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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.

650 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