hWnd and hDC conversions 
Author Message
 hWnd and hDC conversions

I am using an old graphics library which requires an hDC to the object I
wish to draw to. In order to get this I have a function that passes in the
IntPtr from the .NET application. I figured it would make more sense to pass
the handle in and call GetDC from the SDK to get the device context to draw
to...if this doesn't sound like a good idea for a .NET component library
please talk me out of it. I would like my class to write the graphics onto
.NET visual components, such as forms or PictureBoxes or whatnot; when I
wrote this library using VB 6 and ATL I passed in a handle and got the DC
like this which made things much easier.

So my basic steps so far are this:

1. get the Handle (HWND) of the object being drawn on
2. call GetDC on the handle to get device context
3. use old graphics library to draw graphics

My question is, how do you convert the Handle ( IntPtr ) into something that
GetDC can understand(HWND) ?

[VB.NET]

Dim can as New Canvas()
can.hWnd = MyBase.Handle

[c++]

void Canvas::set_hWnd( IntPtr newVal)
{

Quote:
}

Thanks,
Lucas Vogel


Wed, 08 Jun 2005 14:44:32 GMT  
 hWnd and hDC conversions
Lucas,

Quote:

> My question is, how do you convert the Handle ( IntPtr ) into something
that
> GetDC can understand(HWND) ?

> [VB.NET]

> Dim can as New Canvas()
> can.hWnd = MyBase.Handle

> [c++]

> void Canvas::set_hWnd( IntPtr newVal)
> {

> }

HWND hWnd = (HWND)newVal.ToPointer();

--
Tomas Restrepo



Wed, 08 Jun 2005 20:03:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HDC, HWND etc. as arguments in COM

2. Getting HWND from HDC

3. Can I get an HDC from an HWND?

4. Conversion from System::IntPtr to HWND

5. How to get HWND in ::GetDlgItem(HWND hDlg,ID_SECTIONS) before dlg.DoModal()

6. Question on HWND hDlg Parameter in ::SetDlgItemText(HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount)

7. How to get HWND in ::GetDlgItem(HWND hDlg,ID_SECTIONS) before dlg.DoModal()

8. HWND hWnd

9. Question on HWND hDlg Parameter in ::SetDlgItemText(HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount)

10. DestroyWindow( HWND hWnd ) doesnt kill window

11. retrieving a HWND hWnd from a UINT wParam

12. Ever seen debug build HWND != release HWND

 

 
Powered by phpBB® Forum Software