Access Violation when trying to print from ASPX using IE9 on Windows 7 32 bit
Thanks for your time! I could really use your help on an Access Violation issue that I encountered when using a VC++ dll in my VB.NET Web Application. One point of interest here is that it occurs only on IE9 operating on a 32 bit ( but not on the 64 bit version) Windows 7 Enterprise machine.
The usual methodology for Printing is used here. We use the HTMLDocument and create LPOLECOMMANDTARGET pointer to the document. We make a call using the pointer->Exec while using OLECMDID_PAGESETUP which opens the PageSetup Dialog. After this, another Exec call is made using OLECMDID_PRINT to print the page.
lpTarget->Exec(NULL, OLECMDID_PAGESETUP, OLECMDEXECOPT_PROMPTUSER, NULL , NULL);
lpTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, NULL , NULL);
Before these calls are made, we get the Dialogs for Header,Footer,Margins and using a call back function for generating the PageSetup dialog, we set custom values for the Headers and Footers before printing the document. We use the CBT Hook Codes: HCBT_CREATEWND,HCBT_ACTIVATE,HCBT_DESTROYWND to generate the Headers and Footers. It is here that the Access Violation Error is encountered.
We attempt to Click an OK Button using the SendMessage Function: SendMessage(okHWND,BM_CLICK,0,0) for the Footer dialog.This results in an access violation error at location 0x000005 for 0x000000. The weird part is that this error is only reproducible on IE9 + Windows 7 32 bit. I tested on IE9 + Windows 7 64 bit and did not get any errors!
I have verified that the handle for the OK button (okHWND) is not NULL. I have tried using WM_LBUTTONDOWN and WM_LBUTTONUP instead of BM_CLICK, but to no avail..
I did come across a partial fix though. When I replaced SendMessage with PostMessage, I did not get any crash. But the PageSetupDialog appeared for a millisecond and disappeared; i.e,
Pagesetup was by-passed and the file started printing.
Can any of you throw some light into this matter?