Ask About How To Use Startdoc(), Startpage() To Pr

Ask about how to use startdoc(), startpa

Page 1 of 1

1 Replies - 5924 Views - Last Post: 31 July 2002 - 10:34 AM Rate Topic: -----

#1 ooosawaddee3  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 25-July 02

Ask About How To Use Startdoc(), Startpage() To Pr

Post icon  Posted 31 July 2002 - 09:43 AM

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()) ;

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

Is This A Good Question/Topic? 0
  • +

Replies To: Ask About How To Use Startdoc(), Startpage() To Pr

#2 ooosawaddee3  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 25-July 02

Re: Ask About How To Use Startdoc(), Startpage() To Pr

Posted 31 July 2002 - 10:34 AM

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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1