Member_2_99151
asked on
Changing target printer from WebBrowser Control...
Hi,
I have an MFC app that has a Dialog containing the Microsoft WebBrowser control.
Once I have navigated to the appropriate URL, I wish to initiate a 'Print' however, I wish to change the target printer programmatically beforehand and set it back afterwards.
I loacated some source on Microsoft's MSDN for a function called 'GetPrinterDevice' that returns the appropriate hDevMode and hDevNames to the required printer; see
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q166/1/29.asp&NoWebContent=1
I therefore have the following:
HGLOBAL hDevMode = NULL;
HGLOBAL hDevNames = NULL;
if (GetPrinterDevice(_T("MyPr inter"), &hDevNames, &hDevMode))
{
const LECMDEXECOPT_DONTPROMPTUSE R = 2;
const IDM_PRINT = 6;
AfxGetApp()->SelectPrinter (hDevNames , hDevMode); // Default to MyPrinter
TheDocument->ExecWB(IDM_PR INT, LECMDEXECOPT_DONTPROMPTUSE R, 0, 0);
}
else
{
AfxMessageBox(_T("Failed to select 'MyPrinter'."));
}
If I misspell the required printer, the AfxMessageBox pops up, so the function appears to be <almost> working, however, ExecWB still prints to the normal Windows Default printer!!!
Can anyone tell me where I'm going wrong???
Thanks,
James
I have an MFC app that has a Dialog containing the Microsoft WebBrowser control.
Once I have navigated to the appropriate URL, I wish to initiate a 'Print' however, I wish to change the target printer programmatically beforehand and set it back afterwards.
I loacated some source on Microsoft's MSDN for a function called 'GetPrinterDevice' that returns the appropriate hDevMode and hDevNames to the required printer; see
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q166/1/29.asp&NoWebContent=1
I therefore have the following:
HGLOBAL hDevMode = NULL;
HGLOBAL hDevNames = NULL;
if (GetPrinterDevice(_T("MyPr
{
const LECMDEXECOPT_DONTPROMPTUSE
const IDM_PRINT = 6;
AfxGetApp()->SelectPrinter
TheDocument->ExecWB(IDM_PR
}
else
{
AfxMessageBox(_T("Failed to select 'MyPrinter'."));
}
If I misspell the required printer, the AfxMessageBox pops up, so the function appears to be <almost> working, however, ExecWB still prints to the normal Windows Default printer!!!
Can anyone tell me where I'm going wrong???
Thanks,
James
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Give your mail ID, I can send that.
ASKER
I've sent it to your Hotmail account...
Thanks again,
James
Thanks again,
James
Okay
Rosh :)
Rosh :)
Done.
Got that file?
Rosh :)
Rosh :)
ASKER
That worked a treat !
I always like the simple solutions... Still awaiting the SDK Download from MS though ;-)
Thanks
James
I always like the simple solutions... Still awaiting the SDK Download from MS though ;-)
Thanks
James
>> Still awaiting the SDK Download from MS though ;-)
Install FlashGet for that faster download. Get that from download.com
All the Best
Install FlashGet for that faster download. Get that from download.com
All the Best
ASKER
I'm currently downloading the SDK! Umm, good old microsoft - almost 200MB !
Do you have a copy of the latest winspool.h file you could send me, or copy the relavant lines in a comment ?
Thanks for the help...
James