How to convert a wxClientDC to HDC? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Puja Bajaj
In need of some credit
In need of some credit
Posts: 5
Joined: Sat Feb 02, 2008 8:47 am
Location: Noida

How to convert a wxClientDC to HDC?

Post 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
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

I've never done it, but I believe you can just do this:

Code: Select all

HDC hdc = GetHdcOf(dc);
Puja Bajaj
In need of some credit
In need of some credit
Posts: 5
Joined: Sat Feb 02, 2008 8:47 am
Location: Noida

Post by Puja Bajaj »

Thank You Timg,

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

Best Regards,
Puja Bajaj
Puja Bajaj
In need of some credit
In need of some credit
Posts: 5
Joined: Sat Feb 02, 2008 8:47 am
Location: Noida

Post 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.
Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post 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);
Post Reply