|
|
1.1 root 1: /*------------------------------------------------------------
2: WELCOME2.C -- A Program that Creates Two Top-Level Windows
3: ------------------------------------------------------------*/
4:
1.1.1.2 ! root 5: #define INCL_WIN
1.1 root 6: #include <os2.h>
7:
8: MRESULT EXPENTRY Client1WndProc (HWND, USHORT, MPARAM, MPARAM) ;
9: MRESULT EXPENTRY Client2WndProc (HWND, USHORT, MPARAM, MPARAM) ;
10:
11: int main (void)
12: {
1.1.1.2 ! root 13: static CHAR szClientClass1 [] = "Welcome2.1",
! 14: szClientClass2 [] = "Welcome2.2" ;
! 15: static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
! 16: FCF_SIZEBORDER | FCF_MINMAX |
! 17: FCF_SHELLPOSITION | FCF_TASKLIST ;
! 18: HAB hab ;
! 19: HMQ hmq ;
! 20: HWND hwndFrame1, hwndFrame2, hwndClient1, hwndClient2 ;
! 21: QMSG qmsg ;
1.1 root 22:
23: hab = WinInitialize (0) ;
24: hmq = WinCreateMsgQueue (hab, 0) ;
25:
26: WinRegisterClass (
1.1.1.2 ! root 27: hab, // Anchor block handle
! 28: szClientClass1, // Name of class being registered
! 29: Client1WndProc, // Window procedure for class
! 30: CS_SIZEREDRAW, // Class style
! 31: 0) ; // Extra bytes to reserve
1.1 root 32:
33: WinRegisterClass (
1.1.1.2 ! root 34: hab, // Anchor block handle
! 35: szClientClass2, // Name of class being registered
! 36: Client2WndProc, // Window procedure for class
! 37: CS_SIZEREDRAW, // Class style
! 38: 0) ; // Extra bytes to reserve
1.1 root 39:
40: hwndFrame1 = WinCreateStdWindow (
1.1.1.2 ! root 41: HWND_DESKTOP, // Parent window handle
! 42: WS_VISIBLE, // Style of frame window
! 43: &flFrameFlags, // Pointer to control data
! 44: szClientClass1, // Client window class name
! 45: NULL, // Title bar text
! 46: 0L, // Style of client window
! 47: NULL, // Module handle for resources
! 48: 0, // ID of resources
! 49: &hwndClient1) ; // Pointer to client window handle
1.1 root 50:
51: hwndFrame2 = WinCreateStdWindow (
1.1.1.2 ! root 52: HWND_DESKTOP, // Parent window handle
! 53: WS_VISIBLE, // Style of frame window
! 54: &flFrameFlags, // Pointer to control data
! 55: szClientClass2, // Client window class name
! 56: " - Window No. 2", // Title bar text
! 57: 0L, // Style of client window
! 58: NULL, // Module handle for resources
! 59: 0, // ID of resources
! 60: &hwndClient2) ; // Pointer to client window handle
! 61:
! 62: WinSendMsg (hwndFrame1, WM_SETICON,
! 63: WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
! 64: NULL) ;
! 65:
! 66: WinSendMsg (hwndFrame2, WM_SETICON,
! 67: WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
! 68: NULL) ;
1.1 root 69:
70: while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
71: WinDispatchMsg (hab, &qmsg) ;
72:
73: WinDestroyWindow (hwndFrame1) ;
74: WinDestroyWindow (hwndFrame2) ;
75: WinDestroyMsgQueue (hmq) ;
76: WinTerminate (hab) ;
77: return 0 ;
78: }
79:
80: MRESULT EXPENTRY Client1WndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
81: {
82: static CHAR szText [] = "Welcome to Window No. 1" ;
83: HPS hps ;
84: RECTL rcl ;
85:
86: switch (msg)
87: {
88: case WM_PAINT:
89: hps = WinBeginPaint (hwnd, NULL, NULL) ;
90:
91: WinQueryWindowRect (hwnd, &rcl) ;
92:
1.1.1.2 ! root 93: WinDrawText (hps, -1, szText, &rcl, CLR_NEUTRAL, CLR_BACKGROUND,
1.1 root 94: DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
95:
96: WinEndPaint (hps) ;
97: return 0 ;
98: }
99: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
100: }
101:
102: MRESULT EXPENTRY Client2WndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
103: {
104: static CHAR szText [] = "Welcome to Window No. 2" ;
105: HPS hps ;
106: RECTL rcl ;
107:
108: switch (msg)
109: {
110: case WM_PAINT:
111: hps = WinBeginPaint (hwnd, NULL, NULL) ;
112:
113: WinQueryWindowRect (hwnd, &rcl) ;
114:
1.1.1.2 ! root 115: WinDrawText (hps, -1, szText, &rcl, CLR_NEUTRAL, CLR_BACKGROUND,
1.1 root 116: DT_CENTER | DT_VCENTER | DT_ERASERECT) ;
117:
118: WinEndPaint (hps) ;
119: return 0 ;
120:
121: case WM_CLOSE:
122: return 0 ;
123: }
124: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
125: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.