Page 1 of 1

How to convert a wxClientDC to HDC?

Posted: Tue Jun 02, 2009 7:51 am
by Puja Bajaj
Hi,

I am using a 3rd party library which expects me to pass an HDC parameter.

How can I convert the wxClientDC/wxDC object that I have to an HDC?

Thanks in advance,
Puja Bajaj

Posted: Tue Jun 02, 2009 8:21 am
by timg
I've never done it, but I believe you can just do this:

Code: Select all

HDC hdc = GetHdcOf(dc);

Posted: Tue Jun 02, 2009 9:50 am
by Puja Bajaj
Thank You Timg,

Can you also provide me link where I can find documentation of this function.

Best Regards,
Puja Bajaj

Posted: Wed Jun 03, 2009 7:32 am
by Puja Bajaj
Hi,

The hDC that I am using is of a 'wxFrame' class that is current;y displaying and has focus on a list view.

On a user action, I need to pass the hDC of wxFrame to a 3rd party library which should display an image on top. Everything works as expected,however, only the image does not display :-(

Following is my code snippet:

wxClientDC dc(this);
PrepareDC(dc);
this->PrepareDC(dc);

HDC hDC = GetDCOf(dc);
// call the 3rd party API here passing hDC

No effect :-(

Please help.

Posted: Wed Jun 03, 2009 9:16 am
by Frank
Try

wxDC::GetHDC()

This works for me (Copy from a working PDF-Viewer):

Code: Select all

HRESULT hr = PXCV_DrawPageToDC(doc, page, (HDC)dc.GetHDC(), &rp);