Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Draw an CPictureHolder on a Dialog

Posted on 2004-07-30
3
Medium Priority
?
335 Views
Last Modified: 2013-11-20
I'm trying to render a CPictureHolder image onto a dialog.  I've posted my code below, but it's not working.

CPictureHolderEx      pic;
      CDC                              *dc;
      CRect                        crClient;
      CRect                        crPic;
      CStatic                        *frame;


      frame = (CStatic*)this->GetDlgItem(IDC_FRAME);
      frame->GetWindowRect(&crPic);
      GetClientRect(&crClient);
      GetClientRect(&crPic);
      pic.OleLoadPictureFromFile("c:\\test.jpg");
      dc = this->GetDC();
      pic.Render(dc,crPic,crClient);
0
Comment
Question by:lwinkenb
3 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 1600 total points
ID: 11683389
On dialog?
You need to do the rendering in the OnPaint else it is 'removed' by the default OnPaint which will cover the client area by the background colour.  (Load it in OnInitDialog - that is just called once).
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 400 total points
ID: 11684483
Also put your CPictureHolderEx object as a dialog member (in .h)
Put this sentence in the OnInitDialog() function as recommended by Andy:      pic.OleLoadPictureFromFile("c:\\test.jpg");
Put the rest of code in the OnPaint Event.

0
 
LVL 5

Author Comment

by:lwinkenb
ID: 11686028
Thanks for the help guys, that did it.
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!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

824 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