Link to home
Start Free TrialLog in
Avatar of sparkythedog
sparkythedogFlag for Canada

asked on

WIA Printing Wizard

I have a basic MFC dialog application where I have some image thumbnails and based on user selection I will send them to the printer using Windows Image Acquisition Library. Everything is working fine and beautiful but for some reason in the Wizard only the 1st image will be checked fot print. The other ones remains unchecked until the user will select them by hand or by using Select All button.

I didn't found any method until now to select all images automatically so the user won't have to select them again once he selected the in my application.

If you want to take a look to Microsoft sample is here:

http://www.microsoft.com/downloads/details.aspx?familyid=d4738dca-e95c-4d4f-bf32-00a865006c73&displaylang=en

They are using the same library in this sample (is a VB.NET sample but I think won't be any problem for C++ developers :P) for printing and other features in their sample.

Cheers,
Alin
Avatar of DanRollins
DanRollins
Flag of United States of America image

I presume you are calling
    ShowPhotoPrintingWizard

My first thought is to send or post a Ctrl+A keystroke to the list-of-items in the CommonDialog object.

I'll take a furhter look at this later (right now I gotta fly).  For my own reference, the general WIA topic area is here:

      http://msdn.microsoft.com/library/en-us/wiaaut/wia/wiax/overviews/sharedsamples.asp

(I found it a bit hard to locate when I first started looking)

-- Dan
Avatar of sparkythedog

ASKER

Hey, thnaks for the reply.

I tried with sending the keys Ctrl+A but with no success. I'm pretty much run of ideas.

Please let me know if you have found anything meanwhile. I will go through tjeir samples to see whteher I will find something useful.

Thanks,
A-
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey Dan,
I have done it as follows:

        //find the Photo Printing Wizard Dialog
      CWnd* wnd = FindWindow(NULL, "Photo Printing Wizard");
      wnd->SetForegroundWindow();

        //go to the next dialog
      keybd_event(VK_MENU, 0, 0, 0);
      keybd_event('N', MapVirtualKey('N',0), 0, 0);
      keybd_event('N', MapVirtualKey('N',0), KEYEVENTF_KEYUP, 0);
      keybd_event(VK_MENU,0,KEYEVENTF_KEYUP, 0);

       //select all
      keybd_event(VK_MENU, 0, 0, 0);
      keybd_event('S', MapVirtualKey('S',0), 0, 0);
      keybd_event('S', MapVirtualKey('S',0), KEYEVENTF_KEYUP, 0);
      keybd_event(VK_MENU,0,KEYEVENTF_KEYUP, 0);

Everything is working fine, thank you, now I'm just wondering, if the user had open another Photo Printing Wizard from another application or from Windows Explorer, my code it will find the first Printing Wizard Window regardless which on it is. The ICommonDialog object seems that it doesnt have any m_hWnd member that I could use to send the keys, that's why I am using FindWindow method.

A-
Great! I am glad I solved your problem for you!

As to pre-existing open copies of the Wizard...
That could be a problem, and the documentation indicates no direct way to solve it completely.  Here are a couple of ideas to explore:

1) *Before* starting your copy of the wizard, use FindWindows to locate any existing copies.  Record each if their HWND values and then when you do start your own, you can eliminate the others.

2) The one you started will be on the intial "Welcome" page.  It should be easy to recognize it by the contents of one or more buttons or other controls.  Also, I think that the Wizard starts out with a single page, so you can check for the existance of child/owned windows to verify if this is a newly-opened copy.

3) It is possible that one of these functions may help you find a bullet-proof solution:
    GetWindowThreadProcessId()
    GetWindowLong( hwnd, GWL_HINSTANCE)
    GetLastActivePopup()

4) Something MFC does is is temporaily creates a Windows Hook so that it will get control at one critical part of the the window creation process.  I don't recommend that you do that, (it's complicated) but I'm trying to offer a survey of possible rountes.

-- Dan
Perfect thank you,
For now probably I will go with the 1st choice and I willl explore the posibilities of the 3rd one.

Thanks for your help Dan, I will let you know which method finally I will chose and how I will implement it.

Thanks,
Alin