[.net] get HDC from usercontrol object?
I need to get the HDC of a System::Windows::Forms::UserControl object.
All I've found so far is a Handle that's a IntPtr and won't work for the dll function I need to call.
How about something like this:
If it's in an OnPaint method, you don't need to do CreateGraphics(); you can just use the Graphics property of the PaintEventArgs object.
using(Graphics g = this.CreateGraphics()){ IntPtr hdc = g.GetHdc(); // use it here...}
If it's in an OnPaint method, you don't need to do CreateGraphics(); you can just use the Graphics property of the PaintEventArgs object.
Actually what I need is a HDC. I need to pass the value to a function in a dll. It won't let me typecast the IntPtr to a HDC value.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement