Click to See Complete Forum and Search --> : Trouble Setting Focus in Dialog's Button


Shanker
May 7th, 1999, 12:02 AM
This may sound like a simple problem (and perhaps it is) but I've been having some irritation over the following:

All I want to do is create a dialog, and set the default focus and default button (the dotted rectangle) from the OK button to another button. The only way I could do this was to change the tab order manually in the resource editor.

The problem is I want to change it dynamically during program execution, and I tried using the SetFocus() API, but it does not work. Try it yourself! Create a simple dialog box and call this API to set the focus to a desired button---you'll see that it does not work atleast as described in the documentation. What's going on?

Any suggestions, folks?

Cheers,

Shanker.

Srikanth G
May 7th, 1999, 01:23 AM
Hi Shanker,
I got your question. SetFocus() does not work for that. You have to use WM_NEXTDLGCTL message for that.
Read the help for that and you will get it.
PostMessage(WM_NEXTDLGCTL,0,0); can be used to set focus to next item.
You can also set focus to a particular button using that.

Srikanth Software Consultancy
Indian Company working on Visual C++.
29-7-34,SURYARAOPET,
VIJAYAWADA-520002.