Undefined Handles

  • Thread starter Thread starter Alison Kakoschke
  • Start date Start date
A

Alison Kakoschke

Hi.

I need to get a device context for a form. I'm doing
this by using Graphics.getHdc();
This returns what appears to be a valid IntPtr, however
when I convert this to a HDC by using either
HDC hdc = (HDC) (void*) myIntPtr; or
HDC hdc = (HDC) myIntPtr.ToInt32();
I get an undefined value for hdc.
I have had this same problem when getting a HWND for the
form - the IntPtr appears to be fine, but upon converting
it I get undefined values.
I'm using .NET 2003 on Windows XP (coding in C++).
Is there any setting or any file I should be including or
a lib I should be linking with for this to work?
Any help would be much appreciated.

Thanks in advance

Alison Kakoschke
 
When I place a watch on the variable I get the following
{HDC__} { unused=<undefined value> }
as its value.
Note that when I define the HDC as a member variable of a
class, I get a valid value. When it is defined local to
a method, I get the above undefined value.
 
Back
Top