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:


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.

Who is Participating?
I presume that you are using code something like this:

      CVector v;
      v.Add( COleVariant("C:\\temp\\cap.gif"),0 );
      v.Add( COleVariant("C:\\temp\\10Years.gif"),1 );
      v.Add( COleVariant("C:\\temp\\expertAwards2006Button.gif"),2 );
      v.Add( COleVariant("C:\\temp\\467222.jpg"),3 );

      VARIANT var;
      var.vt = VT_DISPATCH;
      var.pdispVal = v.m_lpDispatch;

      m_ctlCmnDlg.ShowPhotoPrintingWizard( &var );

The problem is that once you call ShowPhotoPrintingWizard() you lose control of execution, and as far as I can tell, I can see no way to specify to pre-select items in the CVector object.

That means you you will need a separate thread, so you can take action once the wizard is running.  You already mention that you have tried "sending the keys" so I'll assume that you are already that far.

The answer:  
After sending Alt+N to get past the first screen of the wizard, send Alt+S to execute the wizard's internal code for "Select All"

And there you have it :)

-- Dan
I presume you are calling

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:


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

-- Dan
sparkythedogAuthor Commented:
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.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

sparkythedogAuthor Commented:
Hey Dan,
I have done it as follows:

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

        //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.

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:
    GetWindowLong( hwnd, GWL_HINSTANCE)

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
sparkythedogAuthor Commented:
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.