I didn't have printed procedures before before (in order to save things, I used Word Automation printed). Suddenly you want to print text and pictures, and you can't use Word. If you spend a little time to understand Map Mode and print, maybe these content is also a bit for you, the principle is simple, you can save some of you Types :-)
// Author: Onega
#include
pixel_width / INCH_TO_MM * INCH_TO_TWIP; break; default: break;} return pixel_width; // Width, in logical units according to the map_mode} void draw (HDC hdc) {if (hbmp == NULL) {hbmp = (HANDLE) LoadImage ( NULL, bmp_filename, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE);} int map_mode = MM_TWIPS; LPCTSTR map_name = "MM_TWIPS"; SetMapMode (hdc, map_mode); // Each logical unit is mapped to 0.1 millimeter int x = 0;. int y = 0; int line_h = get_line_height (hdc); SelectObject (hdc, GetStockObject (BLACK_PEN)); SetBkMode (hdc, TRANSPARENT); TextOut (hdc, x, y, map_name, strlen (map_name)); y = line_h; if (NULL = hbmp!) {BITMAP bm; GetObject (hbmp, sizeof (BITMAP), & bm); long width = bm.bmWidth; long height = bm.bmHeight; HDC memdc = CreateCompatibleDC (hdc); HGDIOBJ oldbmp = SelectObject ( MEMDC, HBMP); double pixel_size = get_screen_pixel_width (map_mode); int bmp_draw_width = (int)); int bmp_draw_ height = (int) (height * pixel_size); StretchBlt (hdc, x, y, bmp_draw_width, -bmp_draw_height, memdc, 0,0, width, height, SRCCOPY); SelectObject (memdc, oldbmp); DeleteDC (memdc);} else {LPCTSTR error_msg = "failed to load bitmap from file"; TextOut (hdc, x, y, error_msg, strlen (error_msg));}} int WINAPI WinMain (hINSTANCE hInstance, hINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
MSG msg; WNDCLASSEX wndclass; HMENU hMenu, hMenuA; wndclass.cbSize = sizeof (wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = NULL; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = "PrintDemo"; wndclass.hIconSm = NULL ; RegisterClassEx (& wndclass); hwMain = CreateWindow (wndclass.lpszClassName, NULL, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500,568, NULL, NULL, hInstance, NULL); hMenu = CreateMenu (); hMenuA = CreateMenu (); AppendMenu (hMenuA, MF_STRING , Id_file_print, "print"); appendmenu (HMENU, MF_POPUP, (UINT) HMENUA, "File"); SetMenu (HWMain, HMENU); ShowWindow (HWMAIN, ICMDSHOW); UpdateWindow (HWMAIN); While (GetMessage (& MSG, NULL) , 0, 0)) {TranslateMessage (& MSG); DispatchMessage (& MSG);} Return Msg.wparam;