In first - need DEFINE BUTTON ID(or another object ID) in begin code:
#define ID_BUTTON1 105
Then AFTER creationale of hWnd - we make button:
HWND HwndButton1 = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed
L"OK", // Button text
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles
10, // x position
10, // y position
100, // Button width
100, // Button height
hWnd, // Parent window
(HMENU) ID_BUTTON1, // ID кнопки в меню
NULL, // Сущность мне неведомая 8-)
NULL); // Pointer not needed.
And then add trigger in function:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId=0, wmEvent; //wmId NEED DEFINE null - if he is not available in event, else be ашипка
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmEvent = HIWORD(wParam); // Name of EVENT - имя события
wmId = LOWORD(wParam); // ID element for event - элемент с которым оно случилось
case WM_LBUTTONDOWN: MessageBox(NULL, L"MouseL_Click", L"WndHeader", MB_OK | MB_ICONEXCLAMATION); // Left Mouse Button pressed
if( LOWORD(wParam) == 105 && WM_COMMAND == WM_LBUTTONDOWN){ // Клик по ID_BUTTON1 левым мышком
EndDialog(hWnd,0);
}
................ // Many another function
}
Sleep()
(note the capitalS
) smells like windows. – Eugeniaeugenicskeybd_event()
is a Windows API function. – KleeSleep()
I wasn't. – Eugeniaeugenics