Jump to content
  • Advertisement

Archived

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

KaneBlackflame

Printing with TextOut? Anything Better?

This topic is 6267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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

Share this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!