![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Jan 2002
Posts: 68
| 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()) ; ------------------------------------------------------------ |
| ooosawaddee3 is offline | |
| | #2 |
| Registered User Join Date: Jan 2002
Posts: 68
| 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 |
| ooosawaddee3 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| xor linked list | adramalech | C Programming | 23 | 10-14-2008 10:13 AM |
| Abnormal Program Termination when executed from C:\Program Files\... | m37h0d | Windows Programming | 48 | 09-26-2008 03:45 AM |
| Scope And Parameter Passing | djwicks | C Programming | 6 | 03-28-2005 08:26 PM |
| How do I match 2 files to print data. | sketchit | A Brief History of Cprogramming.com | 0 | 11-12-2001 05:45 PM |
| How to print out the data throw printer.Attn Salem | Jason | C Programming | 2 | 09-23-2001 05:58 AM |