|
|
1.1 root 1: /*-------------------------------------------------------------
2: WELCOME4.C -- Creates a Top-Level Window and Three Children
3: -------------------------------------------------------------*/
4:
5: #define INCL_WIN
6: #include <os2.h>
7:
8: #define ID_BUTTON 1
9: #define ID_SCROLL 2
1.1.1.2 ! root 10: #define ID_ENTRY 3
1.1 root 11:
12: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
13:
14: int main (void)
15: {
1.1.1.2 ! root 16: static CHAR szClientClass [] = "Welcome4" ;
! 17: static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
! 18: FCF_BORDER | FCF_MINBUTTON |
! 19: FCF_SHELLPOSITION | FCF_TASKLIST ;
! 20: HAB hab ;
! 21: HMQ hmq ;
! 22: HWND hwndFrame, hwndClient ;
! 23: QMSG qmsg ;
! 24: RECTL rcl ;
1.1 root 25:
26: hab = WinInitialize (0) ;
27: hmq = WinCreateMsgQueue (hab, 0) ;
28:
29: WinRegisterClass (
1.1.1.2 ! root 30: hab, // Anchor block handle
! 31: szClientClass, // Name of class being registered
! 32: ClientWndProc, // Window procedure for class
! 33: CS_SIZEREDRAW, // Class style
! 34: 0) ; // Extra bytes to reserve
1.1 root 35:
36: hwndFrame = WinCreateStdWindow (
1.1.1.2 ! root 37: HWND_DESKTOP, // Parent window handle
! 38: WS_VISIBLE, // Style of frame window
! 39: &flFrameFlags, // Pointer to control data
! 40: szClientClass, // Client window class name
! 41: NULL, // Title bar text
! 42: 0L, // Style of client window
! 43: NULL, // Module handle for resources
! 44: 0, // ID of resources
! 45: &hwndClient) ; // Pointer to client window handle
! 46:
! 47: WinSendMsg (hwndFrame, WM_SETICON,
! 48: WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
! 49: NULL) ;
1.1 root 50:
51: /*--------------------------------------------------------
52: Find dimensions of client window for sizes of children
53: --------------------------------------------------------*/
54:
55: WinQueryWindowRect (hwndClient, &rcl) ;
1.1.1.2 ! root 56: rcl.xRight /= 3 ; // divide width in thirds
1.1 root 57:
58: /*---------------------------
59: Create push button window
60: ---------------------------*/
61:
62: WinCreateWindow (
1.1.1.2 ! root 63: hwndClient, // Parent window handle
! 64: WC_BUTTON, // Window class
! 65: "Big Button", // Window text
! 66: WS_VISIBLE // Window style
1.1 root 67: | BS_PUSHBUTTON,
1.1.1.2 ! root 68: 10, // Window position
1.1 root 69: 10,
1.1.1.2 ! root 70: (SHORT) rcl.xRight - 20, // Window size
1.1 root 71: (SHORT) rcl.yTop - 20,
1.1.1.2 ! root 72: hwndClient, // Owner window handle
! 73: HWND_BOTTOM, // Placement window handle
! 74: ID_BUTTON, // Child window ID
! 75: NULL, // Control data
! 76: NULL) ; // Presentation parameters
1.1 root 77:
78: /*--------------------------
79: Create scroll bar window
80: --------------------------*/
81:
82: WinCreateWindow (
1.1.1.2 ! root 83: hwndClient, // Parent window handle
! 84: WC_SCROLLBAR, // Window class
! 85: NULL, // Window text
! 86: WS_VISIBLE // Window style
1.1 root 87: | SBS_VERT,
1.1.1.2 ! root 88: (SHORT) rcl.xRight + 10, // Window position
1.1 root 89: 10,
1.1.1.2 ! root 90: (SHORT) rcl.xRight - 20, // Window size
1.1 root 91: (SHORT) rcl.yTop - 20,
1.1.1.2 ! root 92: hwndClient, // Owner window handle
! 93: HWND_BOTTOM, // Placement window handle
! 94: ID_SCROLL, // Child window ID
! 95: NULL, // Control data
! 96: NULL) ; // Presentation parameters
! 97:
! 98: /*---------------------------
! 99: Create entry field window
! 100: ---------------------------*/
1.1 root 101:
102: WinCreateWindow (
1.1.1.2 ! root 103: hwndClient, // Parent window handle
! 104: WC_ENTRYFIELD, // Window class
! 105: NULL, // Window text
! 106: WS_VISIBLE // Window style
! 107: | ES_MARGIN
! 108: | ES_AUTOSCROLL,
! 109: 2 * (SHORT) rcl.xRight + 10, // Window position
1.1 root 110: 10,
1.1.1.2 ! root 111: (SHORT) rcl.xRight - 20, // Window size
1.1 root 112: (SHORT) rcl.yTop - 20,
1.1.1.2 ! root 113: hwndClient, // Owner window handle
! 114: HWND_BOTTOM, // Placement window handle
! 115: ID_ENTRY, // Child window ID
! 116: NULL, // Control data
! 117: NULL) ; // Presentation parameters
! 118:
1.1 root 119: while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
120: WinDispatchMsg (hab, &qmsg) ;
121:
122: WinDestroyWindow (hwndFrame) ;
123: WinDestroyMsgQueue (hmq) ;
124: WinTerminate (hab) ;
125: return 0 ;
126: }
127:
128: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
129: {
130: switch (msg)
131: {
132: case WM_COMMAND:
133: switch (COMMANDMSG(&msg)->cmd)
134: {
135: case ID_BUTTON:
136: WinAlarm (HWND_DESKTOP, WA_NOTE) ;
137: return 0 ;
138: }
139: break ;
140:
141: case WM_ERASEBACKGROUND:
142: return 1 ;
143: }
144: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
145: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.