Thread: Set Printer Prior To Loading Print Dialog Box

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    15

    Set Printer Prior To Loading Print Dialog Box

    Hello,

    In my application, the user selects the printer for the application on a menu screen. At print time I am loading a dialog box and want the previously selected printer to default into the dialog box (under the "Name:" field) as the printer but it is always being populated with the Windows Default Printer instead of the selected printer. Below is my code... any suggestions are appreciated. Thank you in advance for your help and time!


    Code:
    // PRINTER SELECTED BY USER IN BSTR, CSTRING, AND LPCTSTR FORM
    
    CString str = g_csCustomPrinter;
    LPCTSTR lpctstr  = g_csCustomPrinter;
    BSTR bstr = str.AllocSysString();
    
    // NEED SOMETHING HERE TO POPULATE DIALOG BOX WITH PRINTER
    						
    CPrintDialog cPrint(FALSE, PD_HIDEPRINTTOFILE | PD_NOPAGENUMS | PD_NOSELECTION, parent_view);
    // THIS LOADS THE PRINT DIALOG BOX					
    if(cPrint.DoModal() == IDOK)
    {
         //EXECUTE SOME CODE
    }
    Last edited by Beaner; 10-10-2008 at 12:49 PM.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Post more code. And put MFC questions on the Windows board next time. What specifically do you want to do? This?

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    And put MFC questions on the Windows board next time.
    Yes... and moved!
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    15
    Sorry if I posted this in the wrong location. Thanks for your response... i apoligize if my first post was confusing maybe this will help:

    g_csCustomPrinter is a global variable that was captured in another .cpp file... it is the one i want defaulted when the print dialog box is loaded

    The orange line is where i am setting options on the print dialog box to "greyed out" so the user cannot change the selections of these items.

    cPrint.DoModal() opens the print dialog box so the user can select printing objects and once OK is clicked on the print dialog box it will execute the //EXECUTE SOME CODE

    What i want to do is take the printer selected by the user earlier that is stored in g_csCustomPrinter and set it in the red or orange section so when it gets to cPrint.DoModal() to open the print dialog box it will have the printer selected by the user default instead of the Windows Default Printer

    The Print Dialog Box I am trying to populate is much like the print box you get when you use Internet Explorer and select Print... In Internet explorer you will have a list of your available printers available in the Select Printer area with the default one to be used highlighted in blue.... this is similar to what i am doing... in my dialog box it is highlighting the Windows Default Printer in blue (selected) instead of the one the user selects in my application g_csCustomPrinter ... i want the printer saved in the g_csCustomerPrinter to be selected when the dialog box is loaded...

    i hope this clears things up instead of making it more confusing... thanks very much for your time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 02:20 AM
  2. dialog box problem keeps haunting me
    By Bleech in forum Windows Programming
    Replies: 2
    Last Post: 08-23-2006, 01:12 AM
  3. validate data in a dialog box
    By COBOL2C++ in forum Windows Programming
    Replies: 4
    Last Post: 09-22-2003, 01:55 PM
  4. Dialog Box Resources
    By Mecnels in forum Windows Programming
    Replies: 2
    Last Post: 04-28-2003, 05:57 AM
  5. Replies: 5
    Last Post: 09-03-2001, 09:45 PM