TheSwamp

Code Red => .NET => Topic started by: dann.boy.001 on June 09, 2010, 10:22:09 AM

Title: AutoCAD window hDC
Post by: dann.boy.001 on June 09, 2010, 10:22:09 AM
Hello!

Is posible to get hDC window of AutoCAD?

I want to use it to draw on autocad window with
windows api (in net system.drawing.graphics).

Maybe somebody know is posible it  :?

Best regards,
Danijel
Title: Re: AutoCAD window hDC
Post by: Keith™ on June 09, 2010, 11:40:44 AM
It's possible ... I'll have to look up the reference though
Title: Re: AutoCAD window hDC
Post by: Keith™ on June 09, 2010, 12:12:12 PM
To get the device context, you use the GetDC API call

Code: [Select]
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Dim hDC As Long = GetDC(hWndToAutoCAPApplication)

You may have to use IntPtr as the type though ... I have not tried it
Title: Re: AutoCAD window hDC
Post by: dann.boy.001 on June 10, 2010, 05:25:26 AM

Thank you Keith!

I will try this code, but I am not sure how to get hWndToAutoCAPApplication!

Best regards,
Danijel
Title: Re: AutoCAD window hDC
Post by: Keith™ on June 10, 2010, 08:54:55 AM

Thank you Keith!

I will try this code, but I am not sure how to get hWndToAutoCAPApplication!

Best regards,
Danijel

:lmao: ok, sorry, that is the hWnd of the application window you want to modify ... presumably you have a reference to the application window, just not the hDC ... so you should have a hWnd property ... just pass that value to the function.
Title: Re: AutoCAD window hDC
Post by: jgr on June 12, 2010, 04:31:00 PM
p/invoke?... Why?:

Code: [Select]
Graphics.FromHwnd
See:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromhwnd%28v=VS.71%29.aspx