Actually I want to print to two printers continuously one after another. First one to Kyosera 1000 next Kyosera 2500. this happens to all printers.
I can select printers using the code i posted #1 but if i send message to click OK button (or even i tried to click manually) it prints to previous printer (first one).
I heared that I need to notify the parent window (Print dialog) using CBN_SELCHANGE. is it true? if so, how to do that?
Re: Problem in sending the job to printer through API
I tried using CB_SETCURSEL before and had the same issue. It was selected but really wasnt selected. The CBN_SELCHANGE should work but I havent used it.
I used a different approach. I used the WM_KEYDOWN and WM_KEYUP with the SendMessage API in a loop after finding out which index was currently selected with the CB_GETCURSEL message. The return is the selected index and I would SendMessage with the WM_KEYUP or WM_KEYDOWN depending on the position of the selection. You will need to pass the VK_UP or VK_KEYDOWN as the wParam parameter with the WM_KEYDOWN or UP.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Problem in sending the job to printer through API
I have no doubt that sending WM_KEYDOWN/UP will work, but that could require a fair amount of calls. As you've already mentioned you should send CBN_SELCHANGE to the main window after you've made the selection. The CBN_SELCHANGE is sent as part of a WM_COMMAND message.
Re: Problem in sending the job to printer through API
Well, I can't test the code since on XP the Print dialog box doesn't show a combobox for the different printers but a ListView instead. But the above is how the CBN_SELCHANGE notification should be sent.
Re: Problem in sending the job to printer through API
Joacim,
The word print dialog box will have similar Print dialog box with combo box to select printer. You can test it with Word Print dialog. (FYI: I am not automating Word.)
Re: Problem in sending the job to printer through API
But in word I am unable to get handle of combo box. my third party application will have similar print dialog with combo box but we can find the handle using Findwindowx. I will try to give some other example applications.
Re: Problem in sending the job to printer through API
Yeah, the Word print dialog doesn't seem to use a regular combo box at all. When I enumerate the child windows of the Word print dialog all I get is a bunch of RichEdit20W classes... Have you tried using Spy++ and monitor the WM_COMMAND message of the Print dialog in the application to see if it sends the CBN_SELCHANGE notification to the dialog window when you do a manual selection?
Re: Problem in sending the job to printer through API
It looks like the ID for the combo box is 101 and not 1 as it was when I used a VB combobox to do the testing. Also, you might need to send the CBN_SELENDOK notification before the CBN_SELCHANGE. You can use the code I posted earlier to do that, but change (CBN_SELCHANGE * &H10000& + 1&) to (CBN_SELCHANGE * &H10000& + 101&). That would give the following code (assuming you have all the constants declared already).
Re: Problem in sending the job to printer through API
Hi Joacim,
Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Many Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks Thanks
Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot! Thanks a Lot!
It works fantastically. I have no words how can I express my happiness.