|
|
1.1 root 1: /*
2: * HELLO.C -- A simple program which calls the OpenDlg library
3: * Created by Microsoft Corporation, 1989
4: */
5: #define INCL_PM
6: #include <os2.h>
7: #include <opendlg.h>
8: #include "hello.h"
9: /*
10: * Globals
11: */
12: HAB hAB;
13: HMQ hMqHello;
14: HWND hWndHello;
15: HWND hWndHelloFrame;
16: CHAR szClassName[] = "Hello World";
17: CHAR szMessage[] = " - File Dialog Sample";
18: CHAR szExtension[] = "\\*.*";
19: CHAR szHelp[] = "Help would go here.";
20: DLF vdlf;
21: HFILE vhFile;
22: /*
23: * Main routine...initializes window and message queue
24: */
25: int cdecl main( ) {
26: QMSG qmsg;
27: ULONG ctldata;
28:
29: hAB = WinInitialize(NULL);
30:
31: hMqHello = WinCreateMsgQueue(hAB, 0);
32:
33: if (!WinRegisterClass( hAB, (PCH)szClassName, (PFNWP)HelloWndProc,
34: CS_SIZEREDRAW, 0))
35: return( 0 );
36:
37: /* Create the window */
38: ctldata = FCF_STANDARD & ~(FCF_ACCELTABLE);
39: hWndHelloFrame = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE, &ctldata,
40: szClassName, szMessage,
41: WS_VISIBLE, NULL, ID_RESOURCE,
42: (HWND FAR *)&hWndHello );
43:
44: WinShowWindow( hWndHelloFrame, TRUE );
45:
46: /* Poll messages from event queue */
47: while( WinGetMsg( hAB, (PQMSG)&qmsg, (HWND)NULL, 0, 0 ) )
48: WinDispatchMsg( hAB, (PQMSG)&qmsg );
49:
50: /* Clean up */
51: WinDestroyWindow( hWndHelloFrame );
52: WinDestroyMsgQueue( hMqHello );
53: WinTerminate( hAB );
54: }
55:
56: MRESULT CALLBACK HelloWndProc(hWnd, msg, mp1, mp2)
57: /*
58: * This routine processes WM_COMMAND, WM_PAINT. It passes
59: * everything else to the Default Window Procedure.
60: */
61: HWND hWnd;
62: USHORT msg;
63: MPARAM mp1;
64: MPARAM mp2;
65: {
66: HPS hPS;
67: POINTL pt;
68: CHARBUNDLE cb;
69: RECTL rcl;
70:
71: switch (msg) {
72:
73: case WM_COMMAND:
74: switch (COMMANDMSG(&msg)->cmd) {
75:
76: case IDM_OPEN: /* Demonstrate Open... dialog call */
77: SetupDLF( &vdlf
78: , DLG_OPENDLG
79: , &vhFile
80: , szExtension
81: , NULL
82: , "Open Title"
83: , szHelp );
84: DlgFile(hWndHelloFrame, &vdlf);
85: break;
86:
87: case IDM_SAVE: /* Demonstrate Save As... dialog call */
88: SetupDLF( &vdlf
89: , DLG_SAVEDLG
90: , &vhFile
91: , szExtension
92: , NULL
93: , "Save Title"
94: , szHelp);
95: lstrcpy( (PSZ)vdlf.szOpenFile, (PSZ)"foo.bar");
96: DlgFile(hWndHelloFrame, &vdlf);
97: break;
98:
99: case IDM_ABOUT:
100: WinDlgBox(HWND_DESKTOP, hWnd, AboutDlgProc,
101: NULL, IDD_ABOUT, NULL);
102: return 0;
103:
104: default: break;
105: }
106: break;
107:
108: case WM_PAINT:
109: /* Open the presentation space */
110: hPS = WinBeginPaint(hWnd, NULL, &rcl);
111:
112: /* Fill the background with Dark Blue */
113: WinFillRect(hPS, &rcl, CLR_DARKBLUE);
114:
115: /* Write "Hello World" in Red */
116: pt.x = pt.y = 0L;
117: cb.lColor = CLR_RED;
118: GpiSetAttrs(hPS, PRIM_CHAR, CBB_COLOR, 0L, &cb);
119: GpiCharStringAt(hPS, &pt, (LONG)sizeof(szClassName)-1, szClassName);
120:
121: /* Finish painting */
122: WinEndPaint(hPS);
123: break;
124:
125: default: return WinDefWindowProc(hWnd, msg, mp1, mp2); break;
126: }
127: return 0L;
128: }
129:
130: MRESULT CALLBACK AboutDlgProc(hDlg, msg, mp1, mp2)
131: /*
132: About... dialog procedure
133: */
134: HWND hDlg;
135: USHORT msg;
136: MPARAM mp1;
137: MPARAM mp2;
138: {
139: switch(msg) {
140: case WM_COMMAND:
141: switch(COMMANDMSG(&msg)->cmd) {
142: case DID_OK: WinDismissDlg(hDlg, TRUE); break;
143: default: break;
144: }
145: default: return WinDefDlgProc(hDlg, msg, mp1, mp2);
146: }
147: return FALSE;
148: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.