#### Archived

This topic is now archived and is closed to further replies.

# Printing with TextOut? Anything Better?

## Recommended Posts

I need to print a short clip of text that''s only a few lines and I am using a dialog box app. I have all the code written except for one issure. I was told to use TextOut() by the help file. I did and each line ended up on a different page. BufferString=EditNotes; for(i=0;BufferString.GetLength()>2;i++) { TempString=BufferString.Left(BufferString.Find("\r\n",0)); BufferString.Delete(0,BufferString.Find("\r\n",0)+2); GetTextExtentPoint32(pPrintDlg.GetPrinterDC(), TempString, TempString.GetLength(), &szMetric); cWidthPels = GetDeviceCaps(pPrintDlg.GetPrinterDC(),HORZRES); xLeft=cWidthPels/10; yTop=(szMetric.cy*5)+(szMetric.cy*i); pDC.FromHandle(pHDC)->TextOut(xLeft, yTop, TempString); //TextOut(pPrintDlg.GetPrinterDC(), xLeft, yTop, TempString, TempString.GetLength()); } Anyone know what I can do to make sure everything is on one page? "Victims...aren''t we all?" -Brandon Lee, the Crow

##### Share on other sites
Oops...already a code error...try this code...the other was my exploring a fix...

BufferString=EditNotes; for(i=0;BufferString.GetLength()>2;i++) { TempString=BufferString.Left(BufferString.Find("\r\n",0)); BufferString.Delete(0,BufferString.Find("\r\n",0)+2); GetTextExtentPoint32(pPrintDlg.GetPrinterDC(), TempString, TempString.GetLength(), &szMetric); cWidthPels = GetDeviceCaps(pPrintDlg.GetPrinterDC(),HORZRES); xLeft=cWidthPels/10; yTop=(szMetric.cy*5)+(szMetric.cy*i); TextOut(pPrintDlg.GetPrinterDC(), xLeft, yTop, TempString, TempString.GetLength()); }

Does this look better?

"Victims...aren''t we all?"
-Brandon Lee, the Crow

##### Share on other sites
i like to use these methods for debugging win32 apps:

for windowed apps, i use OutputDebugString(char*)

and for full screen apps, i create a log file in my code and output to the log file and check it after execution. I know this doesn''t allow for realtime checking, but i just use the first method for real time.

a2k

##### Share on other sites
M''kay...thanks for the tip. But, I need to know about printing multiple lines of text to a printer. I know there is something wrong with my code, I want to know the code to fix it. Nice try though, and thanks for the debug tip.

"Victims...aren''t we all?"
-Brandon Lee, the Crow

• ### Forum Statistics

• Total Topics
628401
• Total Posts
2982456

• 9
• 10
• 9
• 19
• 24