I have 2 buttons. But how to send to " LRESULT CALLBACK WindowProcedure... " that they are pressed?

 hbut2 = CreateWindowEx(NULL, szBtnClassName, "Âûõîä", WS_CHILD | WS_VISIBLE, 300, 300, 200, 40, hwnd, NULL, hThisInstance, NULL); hbut = CreateWindowEx(NULL, szBtnClassName, "Óñòàíîâèòü Lardi Plus", WS_CHILD | WS_VISIBLE, 50, 300, 200, 40, hwnd, NULL, hThisInstance, NULL); HRGN rgn = CreateRoundRectRgn(10, 10, 190, 40, 15, 15); SetWindowRgn(hbut, rgn, TRUE); SetWindowRgn(hbut2, rgn, TRUE); // ---------------------- ShowWindow(hwnd, SW_SHOWNORMAL); UpdateWindow(hwnd); 
  • And you can ask where you found books about these methods of creating a Windows interface? - Rules
  • On the Internet, I simply dug someone's source code and snatched me the right one - pro

1 answer 1

It is necessary to send the main window WM_COMMAND, in the parameters of which to transmit information about the button. (By the way, you forgot to specify their identifiers when creating buttons).

 //Simulating a button click (ON_BN_CLICKED). //This will simulate the IDC_OK button ebing clicked. WPARAM wParam = BN_CLICKED; wParam = MAKEWPARAM( IDC_OK, BN_CLICKED ); LPARAM lParam = (LPARAM)GetDlgItem(IDC_OK); BOOL bval = ::PostMessage(m_hWnd, WM_COMMAND, wParam, lParam); 

Details see here .

  • Thanks helped! And how to determine which of them is pressed? - pro
  • HWND hbut, nbut2; And I write that IDC_OK variable variable. I called the leader and there IDC_NO is and IDC_OK is mute !!! - pro