WIA Printing Wizard

Posted on 2006-05-19
Last Modified: 2013-11-20
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.

Question by:sparkythedog
    LVL 49

    Expert Comment

    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

    Author Comment

    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.

    LVL 49

    Accepted Solution

    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

    Author Comment

    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.

    LVL 49

    Expert Comment

    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

    Author Comment

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Adapt this command to show who installed 29 99
    Folder Comparison 12 50
    not able to insert into temp table 68 133
    zeroFront challenge 7 58
    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now