|
|
1.1 root 1: /*------------------------------------
2: GRAFMENU.C -- A Menu with Graphics
3: ------------------------------------*/
4:
5: #define INCL_WIN
6: #define INCL_GPI
7:
8: #include <os2.h>
9: #include <stddef.h>
10: #include "grafmenu.h"
11:
12: #define WM_INITIALIZE WM_USER
13:
14: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
15:
16: CHAR szCaption [] = "Graphics Menu" ;
17:
18: int main (void)
19: {
20: static CHAR szClientClass[] = "GrafMenu" ;
21: HAB hab ;
22: HMQ hmq ;
23: HWND hwndClient, hwndFrame ;
24: QMSG qmsg ;
25: ULONG flFrameFlags = FCF_STANDARD ;
26: ULONG flFrameStyle = WS_VISIBLE ;
27:
28: hab = WinInitialize (0) ;
29: hmq = WinCreateMsgQueue (hab, 0) ;
30:
31: WinRegisterClass (hab, szClientClass, ClientWndProc, 0L, 0) ;
32:
33: hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle,
34: &flFrameFlags, szClientClass,
35: szCaption,
36: 0L, NULL, ID_RESOURCE, &hwndClient) ;
37:
38: WinSendMsg (hwndClient, WM_INITIALIZE, NULL, NULL) ;
39:
40: while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
41: WinDispatchMsg (hab, &qmsg) ;
42:
43: WinDestroyWindow (hwndFrame) ;
44: WinDestroyMsgQueue (hmq) ;
45: WinTerminate (hab) ;
46: return 0 ;
47: }
48:
49: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
50: {
51: static MENUITEM miBigHelp = {
52: 0, MIS_BITMAP | MIS_HELP, IDM_HELP, NULL, NULL
53: } ;
54: FONTMETRICS fm ;
55: HBITMAP hbm ;
56: HPS hps ;
57: HWND hwndMenu ;
58:
59: switch (msg)
60: {
61: case WM_INITIALIZE:
62:
63: /*----------------------
64: Load bitmap resource
65: ----------------------*/
66:
67: hps = WinGetPS (hwnd) ;
68: GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;
69: hbm = GpiLoadBitmap (hps, NULL, IDB_BIGHELP,
70: 64 * fm.lAveCharWidth / 3,
71: 64 * fm.lMaxBaselineExt / 8) ;
72: WinReleasePS (hps) ;
73:
74: /*-----------------------
75: Attach bitmap to menu
76: -----------------------*/
77:
78: miBigHelp.hItem = (ULONG) hbm ;
79:
80: hwndMenu = WinWindowFromID (
81: WinQueryWindow (hwnd, QW_PARENT, FALSE),
82: FID_MENU) ;
83:
84: WinSendMsg (hwndMenu, MM_SETITEM,
85: MPFROM2SHORT (0, TRUE), MPFROMP (&miBigHelp)) ;
86: return 0 ;
87:
88: case WM_COMMAND:
89: switch (COMMANDMSG(&msg)->cmd)
90: {
91: case IDM_NEW:
92: case IDM_OPEN:
93: case IDM_SAVE:
94: case IDM_SAVEAS:
95: case IDM_ABOUT:
96: WinAlarm (HWND_DESKTOP, WA_NOTE) ;
97: return 0 ;
98: }
99: break ;
100:
101: case WM_HELP:
102: WinMessageBox (HWND_DESKTOP, hwnd,
103: "Help not yet implemented",
104: szCaption, 0, MB_OK | MB_ICONEXCLAMATION) ;
105: return 0 ;
106:
107: case WM_ERASEBACKGROUND:
108: return 1 ;
109: }
110: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
111: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.