CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    3

    Trouble Setting Focus in Dialog's Button

    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.


  2. #2
    Join Date
    May 1999
    Location
    AP, INDIA
    Posts
    11

    Re: Trouble Setting Focus in Dialog's Button

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured