CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    4

    Getting printer info (printing ENVELOPES)

    I would like to write some code into my application that allows me to print envelopes. The tricky part is figuring out how to set the margins. Some printers feed smaller stock from the center, while others feed from the top or bottom. MSWord has a simple envelope printing option. Is information on how envelopes will be fed stored somewhere in a printer information file?

    I am interested in information on how to determine what margins I should use.

    Thanks,
    Randy


  2. #2
    Join Date
    May 1999
    Location
    Geneva
    Posts
    32

    Re: Getting printer info (printing ENVELOPES)

    Normally, you can have all info of the printer with this code.
    This exemple retrieve the size font from the printer with the DC

    BOOL CMyApp::InitInstance()
    {
    ...

    // These 2 statements are needed to give the app the
    // default printer information. Without them, the call
    // to CreatePrinterDC fails.
    PRINTDLG dlg;
    GetPrinterDeviceDefaults(&dlg);

    CDC dc;
    if (0 != CreatePrinterDC(dc))
    {
    TEXTMETRIC tm;
    dc.GetTextMetrics(&tm);
    int x = dc.GetDeviceCaps(HORZRES);
    int y = dc.GetDeviceCaps(VERTRES);
    ...
    }

    ...
    }


    I hope this will help you

    Niquille Christian




  3. #3
    Join Date
    May 1999
    Posts
    4

    Re: Getting printer info (printing ENVELOPES)

    Thanks, but that doesn't completely answer my question. The question is: Is there a way to tell the printer you're using a standard envelope so that the printer prints the text in the right place. For example, I have a HP 720C and there is an envelope feed slot that is flush with the outside of the paper feed. On my friend's older HP3, the paper feed centers smaller stock. There must be some way to tell the printer: I am printing on this size stock, you figure out where this active area (the area to print on) will be. I looked last night and in the DEVMODE structure, you can specify what size paper/envelopes you are using. Does the printer then know where the stock will be in its bed?

    Does this make sense?

    Thanks,
    Randy


  4. #4
    Join Date
    May 1999
    Location
    Geneva
    Posts
    32

    Re: Getting printer info (printing ENVELOPES)

    I have seen the DEVMODE structure. It normally works, but I have not try to use it.
    You can try to change the value of your printer in the setting, then try to take them with the CPrintDialog::GetDevMode() function

    Christian Niquille


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured