|
|
1.1 root 1: /****************************** Module Header ******************************\
2: * Module Name: HELLO.C
3: *
4: * Example of a simple OS/2 Presentation Manager application
5: *
6: * Created by Microsoft Corp., 1988
7: *
8: \***************************************************************************/
9:
10: #define INCL_PM
11: #include <os2.h>
12: #include "hello.h"
13:
14: HAB hAB;
15: HMQ hmqHello;
16: HWND hwndHello;
17: HWND hwndHelloFrame;
18:
19: CHAR szClassName[] = "Hello";
20: CHAR szMessage[] = "Hello World";
21:
22:
23: /***************************** Private Function ****************************\
24: *
25: * Hello World Main procedure
26: *
27: * Effects: Set globals - hAB Handle to Application Anchor Block
28: * - hmqHello Handle to application window msg queue
29: *
30: * Warnings: None
31: *
32: \***************************************************************************/
33:
34: int cdecl main( )
35: {
36: QMSG qmsg;
37: ULONG ctldata;
38:
39: hAB = WinInitialize(NULL);
40:
41: hmqHello = WinCreateMsgQueue(hAB, 0);
42:
43: if (!WinRegisterClass( hAB,
44: (PCH)szClassName,
45: (PFNWP)HelloWndProc,
46: CS_SYNCPAINT | CS_SIZEREDRAW,
47: 0))
48: return( 0 );
49:
50: ctldata = FCF_STANDARD & ~FCF_MENU;
51:
52: hwndHelloFrame = WinCreateStdWindow( HWND_DESKTOP,
53: WS_VISIBLE | FS_ICON,
54: &ctldata,
55: (PCH)szClassName,
56: (PCH)szMessage,
57: 0L,
58: (HMODULE)NULL,
59: HELLOICON,
60: (HWND FAR *)&hwndHello );
61:
62: WinShowWindow( hwndHelloFrame, TRUE );
63:
64:
65: /* Poll messages from event queue */
66:
67: while( WinGetMsg( hAB, (PQMSG)&qmsg, (HWND)NULL, 0, 0 ) )
68: {
69: WinDispatchMsg( hAB, (PQMSG)&qmsg );
70: }
71:
72: WinDestroyWindow( hwndHelloFrame );
73: WinDestroyMsgQueue( hmqHello );
74: WinTerminate( hAB );
75: }
76:
77:
78:
79: /***************************** Private Function ****************************\
80: *
81: * Procedure which processes window messages
82: *
83: * Effects: None
84: *
85: * Warnings: None
86: *
87: \***************************************************************************/
88:
89: MRESULT EXPENTRY HelloWndProc( hWnd, msg, mp1, mp2 )
90: HWND hWnd;
91: USHORT msg;
92: MPARAM mp1;
93: MPARAM mp2;
94: {
95: HPS hPS;
96: POINTL pt;
97: CHARBUNDLE cb;
98:
99: switch (msg)
100: {
101: case WM_CLOSE:
102: WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
103: break;
104:
105: case WM_PAINT:
106: hPS = WinBeginPaint( hWnd, (HPS)NULL, (PWRECT)NULL );
107: pt.x = pt.y = 0L;
108: cb.lColor = CLR_BLACK;
109: GpiSetAttrs(hPS, PRIM_CHAR, CBB_COLOR, 0L, (PBUNDLE)&cb);
110:
111: GpiCharStringAt( hPS, (PPOINTL)&pt, (LONG)sizeof(szMessage)-1,
112: (PCH)szMessage );
113: WinEndPaint( hPS );
114: break;
115:
116: case WM_ERASEBACKGROUND:
117: return( TRUE );
118: break;
119:
120: default:
121: return( WinDefWindowProc( hWnd, msg, mp1, mp2 ) );
122: break;
123: }
124: return(0L);
125: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.