Solved

Using CPictureHolder

Posted on 2002-05-04
2
585 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 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

24 Experts available now in Live!

Get 1:1 Help Now