Азбука программирования в Win32 API


Азбука программирования в Win32 API - стр. 71


AppendMenu(hFileMenu, MF_GRAYED  MF_STRING, IDM_Exit,"E&xil"); AppendMenu((hHelpMenu=CreatePopupMenu()),MF_DISABLEDMF_STRING,

IDM_About, "&About"); hMenu = CreateMenu(); AppendMenufliMenu, MFJZNABLED | MFJ>OPUP, (UINT) hFileMenu,

AppendMcnu(hMenu, MF_ENABLED | MFJPOPUP, (UINT) hHelpMenu,

"&Help");

SetMenufhWnd, hMcnu); /* Show our window */

ShowWindow(hWnd, nCmdShow);

UpdatcWindow(hWnd);

DrawMenuBar(hWnd);

/* Beginning of messages cycle */

while(GelMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg);

DispatchMessage(&Msg); i t

return Msg.wParam;

LRESULT CALLBACK MenuDemoWndProc (HWND hWnd, UINT Message,

UINT wParam, LONG IParam ) {

RECT Reel; static UINT nFlag - MFJENABLED;

char* pContentf]

i i

"Enable exit",

"Disable exit" };

static UINT nlndex = 0; static НВ1ТМЛР hBitmap; int nDimcnsion;

switch(Message) { caseWM CREATE:

nDimension = GetSystemMetrics(SM_CYMENU);

hBitmap = Loadlmage(hlnst, "msdogs.bmp", IMAGE_BITMAP,

nDimension * 2, nDimension, LR_LOADFROMFILE); AppendMenu(GetMenu(hWnd), MF^BITMAP, IDM_Bitmap, hBitmap); break;

case WM_COMMAND: switch (wParam)

{ case IDM_Enable_Disable:

EnableMenuItem(hFileMenu, IDM_Exit, MF_BYCOMMAND | nFIag);

nFlag = ( nFIag = MF_ENABLED ) ? MF_GRAYED : MFJ-NABLED;

nlndex = ( nlndex == 0) ? I : 0;

ModifyMenu(hFileMenu, IDM_Enable_Disable, MF_BYCOMMAND | MF_STRING, IDM_EnabIe_Disable, pContent[ntndex]);

break; case IDM_Exit:

SendMessage(hWnd, WM_CLOSE, NULL, NULL);

break;

} case WM_SIZE:

SendMessage(hStatusWindow, WM_SIZE, wParam, IParam);

GetClientRect(hWnd, &Rect);

return 0;

case WM_MENUSELECT: // Selection is losted

iff ((UINT) HIWORD(wParam) == Oxffff) & ((HMENU) IParam = 0))

{ SendMessage(hStatusWindow ,SB_SETTEXT, (WPARAM) 0,

(LPARAM) PMessages[5]); return 0;

I if ((UINT) HIWORD (wParam) & MF_SYSMENU)

{ SendMessage(hStatusWindow, SB_SETTEXT, (WPARAM) 0,

(LPARAM) pMessages[6]); return 0;




Начало  Назад  Вперед



Книжный магазин