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


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


152

WndClass.lpfnWndProc = TrackbarWndProc; WndClass.cbClsExtra = 0; 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 = "TrackbarMenu"; WndClass. IpszClassName = szClassName; if ( !RegisterClass(&WndClass) ) {

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

return 0;

hWnd = CreateWindow(szClassName, "Trackbar Demo Program",

WS_OVERLAPPEDWINDOW, CWJJSEDEFAULT, CW_USEDEFAULT, CWJJSEDEFAULT, CWJJSEDEFAULT, NULL, NULL, h!nstance,NULL); if(!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 TrackbarWndProc (HWND hWnd, UINT Message,

UINT wParam, LONG IParam ) {

switch(Message) {

case WM_COMMAND: switch(wParam)

i \

case IDM_Exit: SendMessage(hWnd, WM_CLOSE, 0, 0);

153

break;

case IDM_Dialog;

DialogBox(hInst, "TrackbarDialog", hWnd, TrackbarDialogPruc); break;

}

return 0;

case WMJDESTROY: PostQuitMessage(O); return 0;

return

DefWindowProc(h\Vnd,Mcssage,\vParam, IParam);

BOOL CALLBACK TrackbarDialogProc(HWND hDlg, UINT Message,

WPARAM wParam, LPARAM IParam)

{

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

case WMJNITDIALOG: hEditWnd = GctDlgltemfliDlg, ID_Edit); hTrackbarWnd = GctDlgltem(hDlg, ID J'rackbar); hSpinWnd = CreateUpDownControl(WS_CHILD | WSJ3ORDER |

WS_VISIBLE j UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 0, 12,50,50,

hDlg, !D_Spin, hlnst, hEditWnd, 10,0,5); hTrackbarWnd = CreatcWindow(TRACKBAR_CLASS,"Trackbar Demo",

WS_CHILD | WS_VISIBLE | WS_TABSTOP | TBS_AUTOTICKS, 4,75, 142.40, hDlg, NULL, hlnst, NULL); SendMessagediTrackbarWnd. TBM_SETRANGE, TRUE,




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



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