CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Printing in MFC

  1. #1
    Join Date
    Sep 1999
    Posts
    3

    Printing in MFC

    I'm passing a binary string of PCL commands to a LaserJet printer through our app. However, a reset sent to the printer at the beginning of the print job disables the overlay macro I'm trying to use. Does anyone know where I can look to figure out how to suppress sending a reset at the head of a print job or insert my PCL call just after it? I guess I need to get into the bowels of Windows printing but am at a loss where to begin.
    Thanks.



  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Printing in MFC

    You may have to use the Win32 API Escape() function to write your own PCL character sequences to the printer. This is how I used to do it in Win 3.x a long time ago.

    Regards,

    Paul McKenzie


  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Printing in MFC

    Also, if you take a look at Article Q96795 in MSDN, it describes a Visual Basic program that uses Escape() to write to the printer. Even though it's VB, the Escape() call is a Win API call, and the code is easily changed to C++.

    Regards,

    Paul McKenzie


  4. #4
    Join Date
    Sep 1999
    Posts
    3

    Re: Printing in MFC

    Okay, I'll take a look at the article. However, would this allow me to bypass the reset being sent to the printer by Windows? I'm already sending a PCL sequence but it gets sent before the first page. Would the Escape() allow me to insert into the current page?


  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Printing in MFC

    I'm pretty sure you can control the PCL sequence without Windows sending out codes that you do not want. What function(s) are letting Windows take control of the printer? The only ones that I'm aware of are the GDI functions. There is also StartDoc() and EndDoc() which you may want to investigate. If you are calling StretchBlt() or some other GDI function for the printer, you really have no control of what is going on, since it is the printer driver's responsibility to generate the correct PCL to emulate the GDI call. StartDoc() and EndDoc() may also do something with the printer, but I'm not sure.

    Regards,

    Paul McKenzie


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