|
|
Microsoft OS/2 SDK PM 08-08-1988
/*------------------------------------
GRAFMENU.C -- A Menu with Graphics
------------------------------------*/
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include <stddef.h>
#include "grafmenu.h"
#define WM_INITIALIZE WM_USER
MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
CHAR szCaption [] = "Graphics Menu" ;
int main (void)
{
static CHAR szClientClass[] = "GrafMenu" ;
HAB hab ;
HMQ hmq ;
HWND hwndClient, hwndFrame ;
QMSG qmsg ;
ULONG flFrameFlags = FCF_STANDARD ;
ULONG flFrameStyle = WS_VISIBLE ;
hab = WinInitialize (0) ;
hmq = WinCreateMsgQueue (hab, 0) ;
WinRegisterClass (hab, szClientClass, ClientWndProc, 0L, 0) ;
hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle,
&flFrameFlags, szClientClass,
szCaption,
0L, NULL, ID_RESOURCE, &hwndClient) ;
WinSendMsg (hwndClient, WM_INITIALIZE, NULL, NULL) ;
while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
WinDispatchMsg (hab, &qmsg) ;
WinDestroyWindow (hwndFrame) ;
WinDestroyMsgQueue (hmq) ;
WinTerminate (hab) ;
return 0 ;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
static MENUITEM miBigHelp = {
0, MIS_BITMAP | MIS_HELP, IDM_HELP, NULL, NULL
} ;
FONTMETRICS fm ;
HBITMAP hbm ;
HPS hps ;
HWND hwndMenu ;
switch (msg)
{
case WM_INITIALIZE:
/*----------------------
Load bitmap resource
----------------------*/
hps = WinGetPS (hwnd) ;
GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;
hbm = GpiLoadBitmap (hps, NULL, IDB_BIGHELP,
64 * fm.lAveCharWidth / 3,
64 * fm.lMaxBaselineExt / 8) ;
WinReleasePS (hps) ;
/*-----------------------
Attach bitmap to menu
-----------------------*/
miBigHelp.hItem = (ULONG) hbm ;
hwndMenu = WinWindowFromID (
WinQueryWindow (hwnd, QW_PARENT, FALSE),
FID_MENU) ;
WinSendMsg (hwndMenu, MM_SETITEM,
MPFROM2SHORT (0, TRUE), MPFROMP (&miBigHelp)) ;
return 0 ;
case WM_COMMAND:
switch (COMMANDMSG(&msg)->cmd)
{
case IDM_NEW:
case IDM_OPEN:
case IDM_SAVE:
case IDM_SAVEAS:
case IDM_ABOUT:
WinAlarm (HWND_DESKTOP, WA_NOTE) ;
return 0 ;
}
break ;
case WM_HELP:
WinMessageBox (HWND_DESKTOP, hwnd,
"Help not yet implemented",
szCaption, 0, MB_OK | MB_ICONEXCLAMATION) ;
return 0 ;
case WM_ERASEBACKGROUND:
return 1 ;
}
return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.