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

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-02-17 22:38:33 +0300
committerChristopher Faylor <me@cgf.cx>2000-02-17 22:38:33 +0300
commit1fd5e000ace55b323124c7e556a7a864b972a5c4 (patch)
treedc4fcf1e5e22a040716ef92c496b8d94959b2baa /winsup/mingw/samples/print
parent369d8a8fd5e887eca547bf34bccfdf755c9e5397 (diff)
import winsup-2000-02-17 snapshot
Diffstat (limited to 'winsup/mingw/samples/print')
-rw-r--r--winsup/mingw/samples/print/jamfile9
-rw-r--r--winsup/mingw/samples/print/prntest.c65
2 files changed, 74 insertions, 0 deletions
diff --git a/winsup/mingw/samples/print/jamfile b/winsup/mingw/samples/print/jamfile
new file mode 100644
index 000000000..f5395339d
--- /dev/null
+++ b/winsup/mingw/samples/print/jamfile
@@ -0,0 +1,9 @@
+#
+# A simple example which prints a message on a selected printer. This won't
+# work right unless you make PRINTDLG a packed structure!
+#
+
+Main prntest.exe : prntest.c ;
+
+Gui prntest.exe ;
+
diff --git a/winsup/mingw/samples/print/prntest.c b/winsup/mingw/samples/print/prntest.c
new file mode 100644
index 000000000..801d1d885
--- /dev/null
+++ b/winsup/mingw/samples/print/prntest.c
@@ -0,0 +1,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;
+}