|
|
1.1 root 1: /* msgbox.c - Message box control sample application */
2: /* Created by Microsoft Corp., 1989 */
3: /* */
4: #define INCL_WIN
5: #include <os2.h>
6: #include "msgbox.h"
7:
8: /* Procedure prototypes */
9: MPARAM CALLBACK MsgBoxDlgProc(HWND, USHORT, MPARAM, MPARAM);
10: void cdecl main(void);
11:
12:
13: /* Main routine -- creates a dialog box window */
14: void cdecl main(void)
15: {
16: HAB habMsgBox;
17: HMQ hmqMsgBox;
18:
19: /* Initialize Anchor Block, Message Queue */
20: habMsgBox = WinInitialize(NULL);
21: hmqMsgBox = WinCreateMsgQueue(habMsgBox, 0);
22:
23: /* Summon the dialog box */
24: WinDlgBox(HWND_DESKTOP, NULL, MsgBoxDlgProc, NULL, IDD_MSGBOX, NULL);
25:
26: /* Clean up */
27: WinDestroyMsgQueue(hmqMsgBox);
28: WinTerminate(habMsgBox);
29: }
30:
31: /* Message box control routine */
32: MRESULT CALLBACK MsgBoxDlgProc(hWnd, msg, mp1, mp2)
33: HWND hWnd;
34: USHORT msg;
35: MPARAM mp1;
36: MPARAM mp2;
37: {
38: USHORT flStyle;
39: SHORT rc;
40:
41: switch (msg) {
42: case WM_COMMAND:
43: switch (LOUSHORT(mp1)) {
44: case DID_OK:
45: WinDismissDlg(hWnd, TRUE);
46: break;
47:
48: case IDD_SHOWBOX: /* Show Box */
49: /* Buttons? */
50: rc = (SHORT) WinSendDlgItemMsg(hWnd, IDD_OK0,
51: BM_QUERYCHECKINDEX, 0L, 0L);
52: flStyle = (rc > 0) ? (USHORT) rc : 0;
53:
54: /* Icon style? */
55: rc = (SHORT) WinSendDlgItemMsg(hWnd, IDD_ICON0,
56: BM_QUERYCHECKINDEX, 0L, 0L);
57: if (rc > 0) flStyle = (flStyle & 0xff0f) | ((USHORT) rc << 4);
58:
59: /* Default style? */
60: rc = (SHORT) WinSendDlgItemMsg(hWnd, IDD_DEF0,
61: BM_QUERYCHECKINDEX, 0L, 0L);
62: if (rc > 0) flStyle = (flStyle & 0xf0ff) | ((USHORT) rc << 8);
63:
64: /* Get modality */
65: if (WinSendDlgItemMsg(hWnd, IDD_SYSTEMMODAL, BM_QUERYCHECK, 0L, 0L))
66: flStyle |= MB_SYSTEMMODAL;
67:
68: /* Get help button attribute */
69: if (WinSendDlgItemMsg(hWnd, IDD_HELP, BM_QUERYCHECK, 0L, 0L))
70: flStyle |= MB_HELP;
71:
72: /* Display the Message Box Type */
73: WinSetDlgItemShort(hWnd, IDD_MSGBOXSTYLE, flStyle, FALSE);
74:
75: /* Pop up the message box */
76: rc = WinMessageBox(HWND_DESKTOP, hWnd,
77: (PSZ)"Message Box Text Body\n(can contain several lines)",
78: (PSZ)"This is the title bar", 1, flStyle);
79:
80: /* Update the return code box */
81: WinSetDlgItemShort(hWnd, IDD_RETURNCODE, rc, FALSE);
82: break;
83:
84: default:
85: break;
86: }
87: break;
88:
89: case WM_INITDLG: /* Push these three buttons */
90: WinSendDlgItemMsg(hWnd, IDD_OK0, BM_SETCHECK, (MPARAM) TRUE, 0L);
91: WinSendDlgItemMsg(hWnd,IDD_ICON0, BM_SETCHECK, (MPARAM) TRUE, 0L);
92: WinSendDlgItemMsg(hWnd, IDD_DEF0, BM_SETCHECK, (MPARAM) TRUE, 0L);
93: break;
94:
95: default:
96: return(WinDefDlgProc(hWnd, msg, mp1, mp2));
97: break;
98: }
99: return 0L;
100: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.