?
Solved

Graphics in a dialog based MFC application

Posted on 2003-02-25
6
Medium Priority
?
508 Views
Last Modified: 2013-11-20
I am very new to visual c++ and am having a very difficult time finding out how to add graphics to say a picture box in a dialog based application.  Right now, I would be happy with being able to click a button and have rectangles and circles appear in a picture box I create.  Please help!
0
Comment
Question by:jsano19
  • 4
  • 2
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 200 total points
ID: 8017314
1) Using MFC Class Wizard create new class derived from CStatic (let's call it CMyStatic)
2) Overwrite it's OnPaint message and put drawing code in it
3) In your dialog create picture box with SS_BITMAP style (in dialog editor right-click it and select Bitmap type)
4) Add member variable of type CStatic for this picture box (use Member Variables tab of MFC Class Wizard) - let's call it m_static_picture
5) Include MyStatic.h to dialog h-file
6) Change manually type of m_static_picture variable from CStatic to CMyStatic.

0
 

Author Comment

by:jsano19
ID: 8017584
I tried to do your steps, but run into some problems....
Mainly, adding the member variable of type CStatic in the MFC Class Wizard won't work properly because the picture box I made does not show up as a possible member variable.  do you know why this is?
0
 

Author Comment

by:jsano19
ID: 8017676
Ignore that last comment of mine, I figured that out, just me being stupid.  But, in regards to step 2, the OnPaint message isn't in CMyStatic, I'm trying to figure out how to get it there now, but so far without luck.
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 

Author Comment

by:jsano19
ID: 8017734
Ignore that last comment of mine, I figured that out, just me being stupid.  But, in regards to step 2, the OnPaint message isn't in CMyStatic, I'm trying to figure out how to get it there now, but so far without luck.
0
 

Author Comment

by:jsano19
ID: 8017962
Sorry, I was just being stupid again.  Thanks for your help though, I did get it to work.  Quick question however, does it have to be a bitmap, or can I use frame and things like that instead?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8022952
Nice to see that you solved your problems at the time I was off-line. This should be static control with SS_BITMAP style, exactly as you did (picture control in dialog editor).
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses

599 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