[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

Graphics in MFC Dialog Box

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
RM33
Asked:
RM33
  • 2
1 Solution
 
warmcatCommented:
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
 
kraphicsCommented:
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
 
warmcatCommented:
kraph, download http://warmcat.com/cdib.zip

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now