Solved

Using CPictureHolder

Posted on 2002-05-04
2
612 Views
Last Modified: 2008-03-17
How to use this class to load a jpg to a Picture clip control ver 6.0 ? I need to load the file path, say C:\photos\myphoto.jpg and get it to display in the Microsoft Picture CLip Control, or another control.Any body have experience ? Thanks!
0
Comment
Question by:pigeonbr
[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
2 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 200 total points
ID: 6990906
we meet again ..
you didnt try that clip control did you ? if you need a picture holder its shown below , as i had mentioned you use CPicClip too.
here is how to load a picture from a path

// On_Click()

IPicture *lPic = 0;
if(FAILED(OleLoadPicturePath(L"e:\\test.jpg", 0,0,0, IID_IPicture,(VOID**) &lPic)))
{
  AfxMessageBox ("failed to load picture");
  return ;
}

// CPicClip     m_clip;

m_clip.SetPicture((LPDISPATCH)lPic);
Invalidate();

// On_Paint

1) using picture holder


void CsomeDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CPictureHolder hldr;
hldr.SetPictureDispatch ((IPictureDisp*)m_clip.GetPicture ().m_lpDispatch);
hldr.Render (&dc, CRect(0,0,100,100),  CRect(0,0,100,100));
}

2) without picture holder

long hmWidth;
long hmHeight;
     
hmWidth = m_clip.GetPicture ().GetWidth();
hmHeight = m_clip.GetPicture ().GetHeight();

CRect rct(0,0,100,100);
CPicture pic = m_clip.GetPicture ();

// unfortunaltely, class wizard fails to import Render so we have to resort to the following

IPicture* ipc = 0;
pic.m_lpDispatch->QueryInterface(IID_IPicture, (void**)& ipc);

ipc->Render(
     dc.GetSafeHdc (),
     0,
     0,
     100,
     100,
     0,
     0,
     hmWidth,
     hmHeight,
     (LPCRECT)rct);
ipc->Release();


this should help. note this is just to give you an idea, and placing the image or resiszing should be obvious to you.
0
 

Author Comment

by:pigeonbr
ID: 6994461
ambience:
hi...sorry I don't get back to you too regularly. Ok...I looked at your code. Like I said in the previous question I'm in an ODBC dialog based app, no OnPaint etc...how do I fit in the code for creating a DC? And if there is a way, will the CRect class work, putting the rectangle of the desired sizeat the desired spot in the dialog box just like that?
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

624 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