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


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


#iiiclude "buttons.h"

HINSTANCE hlnst; HWND hWnd ; int nRadioButtonld;

UINT uCheckBoxesState[3] - {MFJJNCHECKED, MF_UNCHECKED, MFJJNCHECKED};

long WINAPI ButtonsExampleWndProc ( HWND, UINT, UINT, LONG ); BOOL CALLBACK ButtonsExampleDialogProc(HWND, UINT, WPARAM,

LPARAM);

int WINAPI WinMain (HINSTANCE hlnstance, HINSTANCE hPrevInstance, LPSTR IpszCmdParam, int nCmdShow )

WNDCLASS WndClass ;

MSG Msg;

char szClassName[] = "ButtonsExample";

hlnst — hlnstance; /* Registering our window class */ /* Fill WNDCLASS structure */

WndClass.style = CSJHREDRAW | CS_VREDRAW;

WndClass.IpfnWndProc = ButtonsExampleWndProc;

WndClass.cbClsExtra = 0;

WndClass.cbWndExtra = 0;

WndClass.hlnstance = hlnstance ;

WndClass.hlcon = Loadlcon (NULL,IDI_APPLICATION);

WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);'

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

WndClass.IpszMenuName = "ButtonsExampleMenu";

WndClass.IpszClassName = szCIassName;

if ( !RegisterClass(&WndClass))

'i

MessageBoxfNULL,"Cannot register class","Error",MB_OK); return 0; ~~ } liWnd ^ CreatcWindow(szClassName, "Button Use Example",

107

WS_OVERLAPPEDWINDOW, CWJJSEDEFAULT, CW_USEDEFAULT, CWJJSEDEFAULT, CW_USEDEFAULT, NULL, NULL, Mnstance,NULL);

ifl[!hWnd)

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

}

InitCommonControls(); /* Show our window */

ShowWindow(hWnd,nCmdShow);

UpdateWindow(hWnd); /* Beginning of messages cycle */

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

{

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

} return Msg.wParam;

LRESULT CALLBACK ButtonsExampleWndProc (HWND hWnd, UINT Message,

UINT wParam, LONG IParam )

{

static BOOL bFlag = FALSE; static HMENU hMenu I , hMenu2; int i;

switch(Message)

{

case WM_CREATE:

hMenu I =GetSubMenu(GetSubMenu(GetMenu(hWnd), 1), 0); hMenu2 = GetSubMenu(GetSubMenu(GetMenu(hWnd), 1), I); CheckMenuRadioItem(hMenu 1 , IDM_RadioButton 1 , IDM_RadioButton3 ,




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



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