Welcome to mirror list, hosted at ThFree Co, Russian Federation.

prntest.c « print « samples « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 801d1d885a6f494945904c20b3cb75fb245844f3 (plain)
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
55
56
57
58
59
60
61
62
63
64
65

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

main ()
{
	PRINTDLG	pd;
	DOCINFO		di;
	char*		szMessage;

	memset (&pd, 0, sizeof(PRINTDLG));
	memset (&di, 0, sizeof(DOCINFO));

	di.cbSize = sizeof(DOCINFO);
	di.lpszDocName = "Test";

	pd.lStructSize = sizeof(PRINTDLG);
	pd.Flags = PD_PAGENUMS | PD_RETURNDC;
	pd.nFromPage = 1;
	pd.nToPage = 1;
	pd.nMinPage = 1;
	pd.nMaxPage = 1;

	szMessage = 0;

	if (PrintDlg (&pd))
	{
		if (pd.hDC)
		{
			if (StartDoc (pd.hDC, &di) != SP_ERROR)
			{
				StartPage (pd.hDC);

				TextOut (pd.hDC, 0, 0, "Hello, printer!", 15);

				EndPage (pd.hDC);

				EndDoc (pd.hDC);

				szMessage = "Printed.";
			}
			else
			{
				szMessage = "Could not start document.";
			}
		}
		else
		{
			szMessage = "Could not create device context.";
		}
	}
	else
	{
		szMessage = "Canceled or printer could not be setup.";
	}

	if (szMessage)
	{
		MessageBox (NULL, szMessage, "Print Test", MB_OK);
	}

	return 0;
}