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

    Help with Escape PASSTHROUGH

    I'm using the Escape function with PASSTHROUGH to send datas to a matrix printer. The datas are sent correctly but the return value of the Escape function is always SP_ERROR. GetLastError() --> 87. (The parameter is incorrect). Any wrong with the following code ?



    BOOL PrintIt()
    {

    CDC dc;
    DOCINFO di;

    CString sName;
    CString msg;
    int iEsc = PASSTHROUGH;


    typedef struct {
    WORD Size;
    char Data[512];
    } PASSTHROUGHSTRUCT;
    PASSTHROUGHSTRUCT MyPassThroughStruct;

    ::ZeroMemory(&di, sizeof (DOCINFO));

    dc.CreateDC(NULL, "MyDotMatrixPrinter", NULL, NULL);

    sName.Format("MyDoc");
    di.cbSize = sizeof (DOCINFO);
    di.lpszDocName = sName;
    di.lpszOutput=NULL;


    dc.StartDoc(&di);

    //dc.StartPage();

    if (!dc.Escape(QUERYESCSUPPORT, sizeof(int), (LPSTR)&iEsc, NULL))
    {
    ... // PassThrough not supported
    }



    MyPassThroughStruct.Size=5;
    sprintf(MyPassThroughStruct.Data,"\x1b@\x1bR\000");
    MyPassThroughStruct.Data[4]='\000';
    if(dc.Escape(PASSTHROUGH,0,(char *) &MyPassThroughStruct,NULL)<0)
    {
    msg.Format("GetLastError: %d",GetLastError());
    MessageBox(msg);
    // Output: GetLastError: 87 (The paramater is incorrect)
    }

    //dc.EndPage();

    dc.EndDoc();


    dc.DeleteDC();

    return TRUE;
    }




    BTW, there are no StartPage() and EndPage() in my function since if I put StartPage() and EndPage() properly, the output to the printer is messed up. Any ideas why it's like that?


  2. #2
    Join Date
    Jul 1999
    Posts
    13

    Re: Help with Escape PASSTHROUGH

    I think you can try this:


    ...
    dc.Escape(PASSTHROUGH,5,"\x1b@\x1bR\000", NULL );
    ...




    May be it help you. No other errors I found.

    Eugene.



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