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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

Using CPictureHolder

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
pigeonbr
Asked:
pigeonbr
1 Solution
 
ambienceCommented:
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
 
pigeonbrAuthor Commented:
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

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now