Skip to main content
gamedev.net
🔒 Locked

Printers...

Started by Meister_J 2 replies 250+ views
Original Post
Meister_J
Meister_J
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!
-J__________________Don't ever frown. You never know when someone is falling in love with your smile.
munkie
munkie
What language are you using?

Arek the Absolute
Arek the Absolute
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:


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

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

PrintDlg(&pd);
HDC ghdc = pd.hDC;

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

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

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

StartDoc(ghdc, &di);
StartPage(ghdc);

// Print your stuff here


EndPage(ghdc);
EndDoc(ghdc);


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]
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Meister_J
Meister_J
Thanks!
-J__________________Don't ever frown. You never know when someone is falling in love with your smile.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.