Solved

Draw an CPictureHolder on a Dialog

Posted on 2004-07-30
3
315 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
[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
3 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 400 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 100 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

Industry Leaders: 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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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