Menard Soliven
2004-06-01 18:58:14 UTC
Hi People,
I'm having trouble passing a Windows Handle ( regardless of whether it
is a Bitmap or Printer Handler ) to the MSHTML Active X control's
IHTMLElementRender interface to the DrawToDC() method using C#.
The first approach that I did was to use the RemotableHandle structure
exposed by mshtml:
// Create a _RemotableHandle instance
mshtml._RemotableHandle dcRemote = new
mshtml._RemotableHandle();
const int WDT_INPROC_CALL = 0x48746457;
dcRemote.fContext = WDT_INPROC_CALL; // or should I use
WDT_REMOTE_CALL ??
dcRemote.u.hInproc = hdcBitmap.ToInt32();
Although the above solved my casting problem, I get an "Invalid
Handle" exception when I pass the above structure to the
IHTMLElementRender.DrawToDC() method.
My second approach was to modify the type library of the
Microsoft.Mshtml.DLL
(a tip I got from this newsgroup) :
1. ILDASM Microsoft.mshtml.dll /out=Microsoft.mshtml.il
2. Modified the handle type in the IL code from "_RemotableHandle" to
int
3. ILASM /DLL Microsoft.mshtml.il /RES=Microsoft.mshtml.res
Although ILDASM worked to produce the lengthy IL code, I can't
successfully assemble the IL back to its original DLL form using ILASM
as I get a "FAILURE MESSAGE".
Any level of help would be greatly appreciated.
Thanks in advance!
Menard
I'm having trouble passing a Windows Handle ( regardless of whether it
is a Bitmap or Printer Handler ) to the MSHTML Active X control's
IHTMLElementRender interface to the DrawToDC() method using C#.
The first approach that I did was to use the RemotableHandle structure
exposed by mshtml:
// Create a _RemotableHandle instance
mshtml._RemotableHandle dcRemote = new
mshtml._RemotableHandle();
const int WDT_INPROC_CALL = 0x48746457;
dcRemote.fContext = WDT_INPROC_CALL; // or should I use
WDT_REMOTE_CALL ??
dcRemote.u.hInproc = hdcBitmap.ToInt32();
Although the above solved my casting problem, I get an "Invalid
Handle" exception when I pass the above structure to the
IHTMLElementRender.DrawToDC() method.
My second approach was to modify the type library of the
Microsoft.Mshtml.DLL
(a tip I got from this newsgroup) :
1. ILDASM Microsoft.mshtml.dll /out=Microsoft.mshtml.il
2. Modified the handle type in the IL code from "_RemotableHandle" to
int
3. ILASM /DLL Microsoft.mshtml.il /RES=Microsoft.mshtml.res
Although ILDASM worked to produce the lengthy IL code, I can't
successfully assemble the IL back to its original DLL form using ILASM
as I get a "FAILURE MESSAGE".
Any level of help would be greatly appreciated.
Thanks in advance!
Menard