-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.cpp
56 lines (53 loc) · 1.29 KB
/
print.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define STRICT
#include <windows.h>
#include "dxw.h"
#include "twnd.h"
#include <commdlg.h>
HGLOBAL hDM = nullptr;
HGLOBAL hDN = nullptr;
/*
static void tst(HDC hdc,RECT&rc)
{
MoveToEx(hdc,rc.left,rc.top,nullptr);
LineTo(hdc,(rc.left+rc.right)/2,rc.bottom);
LineTo(hdc,rc.right,rc.top);
LineTo(hdc,rc.left,(rc.top+rc.bottom)/2);
LineTo(hdc,rc.right,rc.bottom);
LineTo(hdc,(rc.left+rc.right)/2,rc.top);
LineTo(hdc,rc.left,rc.bottom);
LineTo(hdc,rc.right,(rc.top+rc.bottom)/2);
LineTo(hdc,rc.left,rc.top);
}
*/
void
Window::ToPrinter() {
PRINTDLG pd;
pd.lStructSize = sizeof(pd);
pd.hwndOwner = hFrame;
pd.hDevMode = hDM;
pd.hDevNames = hDN;
pd.nCopies = 1;
pd.Flags = PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC;
if (!PrintDlg(&pd)) return;
hDM = pd.hDevMode;
hDN = pd.hDevNames;
DOCINFO di;
di.cbSize = sizeof(di);
di.lpszDocName = "channell";
di.lpszOutput = nullptr;
HCURSOR hc = SetCursor(LoadCursor(nullptr, IDC_WAIT));
StartDoc(pd.hDC, &di);
StartPage(pd.hDC);
SetMapMode(pd.hDC, MM_TEXT);
RECT rc;
rc.top = 0;
rc.left = 0;
rc.right = GetDeviceCaps(pd.hDC, HORZRES);
rc.bottom = GetDeviceCaps(pd.hDC, VERTRES);
Draw(pd.hDC, rc, Printer);
//tst(pd.hDC,rc);
EndPage(pd.hDC);
EndDoc(pd.hDC);
DeleteDC(pd.hDC);
SetCursor(hc);
}