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


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


WndClass.cbWndExtra - 0;

WndClass.hinstance = hinstance ;

WndClass.hlcon = Loadlcon (NULL,IDI_APPLICATION);

WndClass.hCursor = LoadCursor (NULL, IDC ARROW);

WndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

WndClass.IpszMenuName = "MyMenu";

WndClass.IpszClassName = "MenuExample";

if ( !RegisterClass(&WndClass)) !

MessageBox(NULL,"Cannot register class","Error",MB_OK); return 0;

} hWnd = CreateWindowC'MenuExample", "Program No 2",

WS_OVERLAPPEDWINDOW,

CWJJSEDEFAULT,

CW_USEDEFAULT,

CWJJSEDEFAULT,

CWJJSEDEFAULT,

NULL, NULL,

hlnstance,NULL); if(!hWnd)

{

MessageBox(NULL,"Cannot create window","Error",MBJ3K); return 0;

InitCoinmonControlsQ;

hStatusWindow = CreateStatusWindow(WSJTHILD | WS_VISIBLE,

"Menu sample",

hWnd,w!d); if(!hStatusWindow)

{

MessageBox(NULL,"Cannot create status window","Error",MB JDK); return 0;

/* Load the accelerators table */

hAccel = LoadAccelerators(hInst,"MyAccelerators"); /* Show our window */

ShowWindow(hWnd,nCmdShow);

UpdateWindow(hWnd);

hFilcMcnu = GetSubMenu(GetMenu(hWnd),0);

/* Beginning of messages cycle */

while(GetMessage(&Msg, NULL, 0, 0)) {

if( !TranslateAccelerator(hWnd,hAccel,&Msg)) {

TranslateMessage(&Msg); DispatchMessage(&Msg);

return Msg.wParam;

long WINAPI HelloWorldWndProc (HWND hWnd, UINT Message,

UINT wParam, LONG IParam )

!

RECT Rect;

static UINT nFIag = MFJENABLED; char* pContent[]

>

t

"&EnabIe exit\te", "&Disable exit\td"

};

static UINT nlndcx = 0;

switch(Message) {

case WMJCOMMAND: switch (wParam)

)

case IDMJinable J3isable:

EnableMenuItem(hFileMenu, IDMJЈxit, MFJBYCOMMAND | nFIag); nFIag - ( nFIag -= MFJZNABLED )'.' MFJ3RAYED : MFJENABLED; nlndex = ( nlndex = 0) ? 1 : 0;

ModifyMcnu(hFileMenu, IDM_Enable_Disable, MF_BYCOMMAND | MF_STRING, IDM_Enable_Disable, pContentfnlndex]); break;

case IDM_Exit:




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



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