Printing with TextOut? Anything Better?

Started by
2 comments, last by KaneBlackflame 22 years, 8 months ago
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
"Victims...aren't we all?" -Brandon Lee, the Crow
Advertisement
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
"Victims...aren't we all?" -Brandon Lee, the Crow
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
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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
"Victims...aren't we all?" -Brandon Lee, the Crow

This topic is closed to new replies.

Advertisement