CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Location
    Azerbaijan
    Posts
    74

    Set a focus to a button

    I want t set a focus on a button. When I use the shown code in MFC for an edit control:

    Code:
    ::SetFocus(
        ::GetDlgItem(
            GetSafeHwnd(), // HWND of the dialog window
            <id> ) );
    everything goes OK. But when I try it for a button it failes.
    However this code:

    Code:
    GetDlgItem( <id> )->SetFocus();
    works well in both cases. What is the difference.

    At last, what I must to do to set focus to a button in WINAPI, if my method is wrong?

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...call 'GetLastError()' to retrieve the specific error code of 'SetFocus()'.

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