Ask about how to use startdoc(), startpage() to print data on paper imediately.

This is a discussion on Ask about how to use startdoc(), startpage() to print data on paper imediately. within the C++ Programming forums, part of the General Programming Boards category; I want to ask about how to use startdoc(), startpage() to print data on paper imediately then receive the next ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    68

    Lightbulb Ask about how to use startdoc(), startpage() to print data on paper imediately.

    I want to ask about how to use startdoc(), startpage() to print data on paper imediately then receive the next data and print imediately and receive the next data and print ......

    Example : If I want to print this below data in first page imediately and after that I receive the other data and print imediately not like Microsoft word which must receive all data and print 1 time.

    110011110

    How to do that loop?

    This below is my program want to do that.

    If first data is 110011110

    I change 1 in the above data to solid black (which have 2 pixel width and 4 pixel height) and 0 in the above data to solid white (which have 2 pixel width and 4 pixel height)

    code:
    ------------------------------------------------------------

    DOCINFO di ;
    CPrintInfo printInfo ;
    CString filename ;
    CDC dc ;
    CRect draw_area ;
    CPrintDialog dlg(FALSE) ;

    if (Dlg.DoModal() == IDCANCEL)
    return ;

    HDC hDC = dlg.GetPrinterDC() ;
    if (hDC == NULL)
    return ;

    di.cbSize = sizeof(DOCINFO) ;
    di.lpszDocName = "Document name"
    di.lpszOutput = NULL ;

    // prepare the print information structure
    dc.Attach(hDC) ;
    printInfo.m_bDirect = TRUE ;
    printInfo.m_rectDraw.left = 0 ;
    printInfo.m_rectDraw.right = dc.GetDeviceCaps(HORZRES) ;
    printInfo.m_rectDraw.top = 0 ;
    printInfo.m_rectDraw.bottom = dc.GetDeviceCaps(VERTRES) ;
    draw_area = printInfo.m_rectDraw ;

    dc.StartDoc(&di) ;

    //receive first data
    CString testline = "110011110" ;

    int x = 0 ;
    int y = 0 ;
    int pos = 0 ;
    // start printing the document

    dc.StartPage() ;

    CBrush brush;

    // Creation of the brush with a black color

    brush.CreateSolidBrush(RGB(0, 0, 0));

    while (pos < testline.GetLength())
    {
    if ((testline.GetAt(pos)) == '1')
    {

    // Create a rectangle with coordinates x,y,x+2,y+4 corresponding with top, left, bottom, right
    CRect Rectangle(x, y, x + 2, y + 4) ;

    // Fill a rectangle in the current device context or DC
    dc.FillRect(&Rectangle , &brush);

    x += 2;
    }

    else if ((testline.GetAt(pos)) == '0'){

    x += 2;
    }
    pos++ ;
    }
    y += 4 ;
    x = 0 ;
    pos = 0 ;

    dc.EndPage() ;
    printInfo.m_rectDraw = draw_area ;

    //OnEndPrinting(&dc, &printInfo);
    dc.EndDoc() ;
    VERIFY(dc.DeleteDC()) ;

    ------------------------------------------------------------

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    68

    Lightbulb

    Or if you can show me the example how to print

    text 1001010 in first page imediately and then receive the second data 1011111 and print in second page imediately and receive the next data and print. Please show me ( by use startdoc(), startpage() , endpage(), enddoc())

    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 07:26 PM
  4. How do I match 2 files to print data.
    By sketchit in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 11-12-2001, 04:45 PM
  5. How to print out the data throw printer.Attn Salem
    By Jason in forum C Programming
    Replies: 2
    Last Post: 09-23-2001, 05:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21