PDA

Click to See Complete Forum and Search --> : Setting Focus


Technocrat
Oct 31st, 2000, 04:27 PM
Anyone know how to set the focus to a button on a form?
Or maybe how to change the tabstop order?

Vlatko
Oct 31st, 2000, 04:50 PM
SendMessage(handleofbutton,WM_SETFOCUS,0,0);

Oct 31st, 2000, 05:09 PM
You shouldnt use SendMessage, you should use SetFocus(hWnd).

Technocrat
Oct 31st, 2000, 06:19 PM
How is there an easy way to get the hWnd of a button on my form??

Oct 31st, 2000, 06:23 PM
hControl= GetDlgItem(hDialog, BUTTON_ID);

Technocrat
Oct 31st, 2000, 06:25 PM
Thanks

Nov 1st, 2000, 06:20 AM
Couldn't you use FindWindow to get a window's handle?


hWin = FindWindow(NULL,"Caption");

HarryW
Nov 1st, 2000, 08:07 AM
What if two windows have the same caption?

parksie
Nov 1st, 2000, 12:57 PM
You get the first window created (I think). Anyway, you'll always have the handle, because if it's a dialogue, use GetDlgItem, and if it's window, you'd have received the handle in the call to CreateWindowEx.