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


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


>

HWND liWnd;

WNDCLASS WndClass ;

MSG Msg;

char szClassNamef] = "SpinDcmo";

hlnst = hlnstance;

144

/* Registering our window class */ /* Fill WNDCLASS structure */

WndClass.stylc = CS_HREDRAW j CS_VREDRAW;

WndClass. IpfnWndProc = SpinDemoWndProc;

WndCiass.cbClsExtra = 0;

WndClass. cbWndExtra = 0;

WndCIass.hlnstance = hlnstance ;

WndClass.hlcon = Loadlcon (NULL,IDI_APPLICATION);

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

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

WndClass. IpszMenuName = "SpinDemoMenu";

WndClass. IpszClassName = szCIassName;

if ( !RegisterClass(&WndClass) ) I

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

hWnd = CreateWindow(szClassName, "Spin Demo",

WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CWJJSEDEFAULT, CWJJSEDEFAULT, NULL, NULL, h!nstance,NULL); if(!hWnd) {

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

InitCommonControlsO; /* Show our window */ ShowWindow(hWnd,nCmaShow); UpdateWindow(hWnd);

/* Beginning of messages cycle */

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

TranslateMcssage(&Msg); DispatchMcssage(&Msg); } return Msg.wParam;

LRESULT CALLBACK SpinDemoWndProc (HWND hWnd, UINT Message,

UINT wParam, LONG IParam ) I switch(Messagc)

145

case \VM_COMMAND: switch(wParam)

{ case IDM_Exil:

SendMessage(hWnd, WM_CLOSE, 0, 0);

break; case IDM_Dialog:

DialogBox(hInst, "SpinDemoDialog", hWnd, SpinDcmoDialogProc);

break;

i /

return 0;

case WM_DESTROY; PostQuitMessage(O); return 0;

I return DefWindowProc(hWnd,Message,wParam, IParam);

BOOL CALLBACK. SpinDemoDialogProc(HWND hDlg, UINT Message,

WPARAM wPararn, LPARAM IParam)

!

static HWND hEditWnd; static HWND hSpinWnd; switch(Message)

{

case WMJNITDIALOG: hEditWnd = GetDlgItem(hDlg,ID_Edit);

hSpinWnd = CreatcUpDownControl(WS_CHILD | WS_BORDER |

WS_VISIBLE ] UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 0, 12,50,50, hDlg, ID_Spin, hlnst,




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



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