Printers...

Started by
2 comments, last by Meister_J 21 years, 10 months ago
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.
Advertisement
What language are you using?

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 hereEndPage(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
Thanks!
-J__________________________________________________________________________________________Don't ever frown. You never know when someone is falling in love with your smile.

This topic is closed to new replies.

Advertisement