[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • 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

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

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