Jump to content
  • Advertisement
Sign in to follow this  
VanKurt

Win32: setting focus impossible!?

This topic is 4044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys! Ich getting crazy trying to set the focus to a button in a dialog. In the WindowProc of the dialog I have the following:
	case WM_INITDIALOG:
		{
			// Set Focus to start button
			SendMessage( hwndDlg, WM_SETFOCUS, (WPARAM)GetDlgItem(hwndDlg, BTN_START), NULL );
			//SetFocus(GetDlgItem(hwndDlg, BTN_START));
	}break;

But neither sending the WM_SETFOCUS message nor using SetFocus() changes a thing. The focus is always on another button, no matter what I do... Any help is apreciated! Thaaaaanks :-D

Share this post


Link to post
Share on other sites
Advertisement
Did you read the MSDN for WM_INITDIALOG?
Quote:
Return Value
The dialog box procedure should return TRUE to direct the system to set the keyboard focus to the control given by hwndFocus. Otherwise, it should return FALSE to prevent the system from setting the default keyboard focus.

Share this post


Link to post
Share on other sites
Sorry, I left that out in the code I posted. But now I found a way: in the settings of the button there is a flag called "default button". If that is set to true, the button is initially focused.

Thank's for your reply!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!