Jump to content
  • Advertisement


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



This topic is 5857 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 just finished up a program for keeping stock and stuff, how do I access a printer to print a reciept? I need to know how to access it and how I arrange the aesthetics of the printed material. Thanks in advance!

Share this post

Link to post
Share on other sites
I'm assuming here you're using C++ for Windows. If that's the case, what you need to do is get a device context to the printer. The easiest way to do this is to create a PRINTDLG structure, and use it with the PrintDlg function. See this code:

memset ((void *) &pd, 0, sizeof(PRINTDLG));

pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = hwnd;
pd.Flags = PD_RETURNDC;
pd.hInstance = NULL;

HDC ghdc = pd.hDC;

if (pd.hDevMode)
GlobalFree (pd.hDevMode);

if (pd.hDevNames)
GlobalFree (pd.hDevNames);

SetMapMode (ghdc, MM_TEXT);
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Test";
di.lpszOutput = NULL;

StartDoc(ghdc, &di);

// Print your stuff here


Most of this is taken more or less straight from MSDN stuff. As far as actually printing what you want to a page, you'd treat it exactly like you would to a window. Any functions like StretchBlt, FrameRect, etc., work just as they do on a window, to my experience anyway.

Hope this helps-
-Arek the Absolute

[edited by - Arek the Absolute on June 9, 2002 9:34:36 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!