CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2007
    Posts
    6

    [RESOLVED] Radio Button problem with WM_NEXTDLGCTL

    Hi There!

    I have the following Problem:

    I have a dialog box with several text controls followed by two radio buttons for a selection. If i use the TAB key to jump from one input field to the next, the Text of the radio button wich has the focus is framed with a dotted rectangle, and the button can be checked with SPACE.
    It is neccessar, that it is possible to switch between the controls also with ENTER. I do this by simply putting PostMessage(WM_NEXTDLGCTL,0,0) in OnOK().
    Basically it works, and the behaviour is just like described above, but the frame arount the text of the radio buttons does not appear, so the user can not see wich button will be checked by pressing SPACE.

    Any idea what i can to to make this frame appear???

    Thanks in advance
    Marc

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: Radio Button problem with WM_NEXTDLGCTL

    Try resetting the focus

    Code:
    CWnd *pWnd=GetFocus();
    if(pWnd) {
      SetFocus(NULL);
      SetFocus(pWnd);
    }
    or it could be a repaint issue, in case this may help
    Code:
    Invalidate();
    or
    Code:
    UpdateWindow();
    or
    Code:
    pWnd->RedrawWindow();
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Jun 2007
    Posts
    6

    Re: Radio Button problem with WM_NEXTDLGCTL

    Thanks, but none of those did the trick!

    I found out that the rectangles appear, if i press the TAB key at least once before i come to the radio buttons with ENTER. Really strange. Maybe i can simulate a TAB keystroke programmatically??

  4. #4
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: Radio Button problem with WM_NEXTDLGCTL

    OK, call this in OnInitDialog, OnInitialUpdate or whatever...

    Code:
    ::PostMessage(m_hWnd, WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0);
    Or, if you get an error that the constants are undefined:
    Code:
    ::PostMessage(m_hWnd, 0x128, MAKEWPARAM(0x2, 0x1), 0);
    More about WM_UPDATEUISTATE here:
    http://msdn2.microsoft.com/en-us/library/ms646361.aspx
    Nobody cares how it works as long as it works

  5. #5
    Join Date
    Jun 2007
    Posts
    6

    Talking Re: Radio Button problem with WM_NEXTDLGCTL

    Whatever that does,

    Code:
    ::PostMessage(m_hWnd, 0x128, MAKEWPARAM(0x2, 0x1), 0);


    works!

    Thank you very much!!

    Marc

  6. #6
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: Radio Button problem with WM_NEXTDLGCTL

    Crystal clear, isn't it

    You're welcome !
    Nobody cares how it works as long as it works

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