Solved

Draw an CPictureHolder on a Dialog

Posted on 2004-07-30
3
267 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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. …
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now