How to make a Win32 API softkey soft?

I have a button, if I say, check the box, then it should focus on one of the two buttons.

I'm not sure how to use BM_SETSTATE - if this is the way to do it.

// snip... case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CHECK: if (IsDlgButtonChecked(hDlg, IDC_CHECK)) { EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE); BM_SETSTATE // ... ?? } else // ... snip 

any help is much appreciated! Many thanks!

+4
source share
2 answers

I'm not sure that you understand exactly what you are asking, but maybe.

The backlight status indicates whether the button is highlighted, as if the user had pressed it. It does not indicate whether the button has focus, and does not indicate whether the button is checked or not.

If you really want to do this, use the Button_SetState macro.


Just in case:

  • If you want to set the validation state to a button, use the Button_SetCheck macro.
  • If you want to set focus on the button, use the SetFocus Win32 API.
  • Note. I mentioned a couple of macros above, you can use SendMessage instead and send the corresponding message as described in the message on MSDN.
+3
source

To make the default button in win32 (which I think is your question), you can simply do this by sending the button a BM_SETSTYLE message with BS_DEFPUSHBUTTON as WPARAM ...

 HWND hwndButton = CreateWindow("button", "OK", WS_VISIBLE |...); SendMessage(hwndButton, BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, TRUE); 

Hope this helps ...; -)

+2
source

All Articles