Work around for missing Graphics.GetHdc() ?

  • Thread starter Thread starter Mark Johnson
  • Start date Start date
M

Mark Johnson

Is there a work around for the missing Graphics.GetHdc() Function in Compact
?

I am trying to call a DLL (pegcards.dll) which needs the
Handle/Adress/IntPrt of the painting space where the results will be stored.

Any help would be welcomed.

Mark Johnson, Berlin Germany
(e-mail address removed)
 
What you need to do is P/Invoke to get the device context. Because the GetDC
API expects a window handle as well, first of you need to get that. To make
P/Invoking easy you might want to use OpenNETCF.org's WinAPI library
(http://www.opennetcf.org/winapi.asp). To get the handle to the window you
want to draw on, you can use something like this (assuming you make use of
the WinAPI library):

control.Capture = true;
IntPtr hWnd = OpenNETCF.Win32.GetCapture();
control.Capture = false;

IntPtr hDC = OpenNETCF.Win32.GetDC(hWnd);

< call into your DLL using the hDC you just obtained >

// Make sure to release the device context again
OpenNETCF.Win32.ReleaseDC(hWND, hDC);

Hope this helps.
 
Thank you for your answer.
This is the code I used and it compile :
#if COMPACT
System.Windows.Forms.Panel panel = (System.Windows.Forms.Panel) sender;
panel.Capture = true;
IntPtr hWnd = Win32Window.GetCapture();
panel.Capture = false;
p_IntPtr = OpenNETCF.WinAPI.Core.GetDC(hWnd);
#else
p_IntPtr = g.GetHdc();
g.ReleaseHdc(p_IntPtr);
#endif

I could not test it because I am recieving a System.MissingMethodException
before it runs.
pegcards.dll seems to have other Methods than cards.dll.

Thankyou
Mark Johnson, Berlin Germany
(e-mail address removed)
 
Having had a look at the Pocket PC 2000 emulator version of pegcards.dll
with depends.exe, it does not expose any methods at all. It does however
contain bitmap resources for all the cards and backs.

Peter
 
Back
Top