• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

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
0
sparkythedog
Asked:
sparkythedog
  • 3
  • 3
1 Solution
 
DanRollinsCommented:
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
0
 
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.

Thanks,
A-
0
 
DanRollinsCommented:
I presume that you are using code something like this:

      CVector v;
      v.CreateDispatch("WIA.Vector");
      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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Thanks,
Alin
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now