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

    edit control in a propertypage

    The problem is as follows:

    I'm using a edit control in a propertypage. When I press enter within the edit control I would like to activate a push button in the same propertypage. i.e., when the user presses enter after typing the data in the edit control some pushbutton has to be activated by default.Any suggestions?


  2. #2
    Join Date
    May 1999
    Posts
    318

    Re: edit control in a propertypage

    A solution could be to override the PretranslateMessage of the CPropertySheet class.
    Then in this function you verify if it is a ENTER key pressed message. To avoid the message to be sent to the default button just return TRUE.


    BOOL CMyClass::PreTranslateMessage(MSG* pMsg)
    {
    if ( pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN && GetFocus()==&m_mytextbox )
    {
    //...
    return TRUE;
    }
    return CPropertySheet::PreTranslateMessage(pMsg);
    }




    I hope this method could help.






  3. #3
    Join Date
    May 1999
    Posts
    116

    Re: edit control in a propertypage

    I've had to resort to this also.
    I tried SetFocus(), SetActiveWindow(), SetForegroundWindow(), and even tried modifying styles of buttons to be DEFPUSHBUTTON, but the wizard keeps changing focus.


  4. #4
    Join Date
    May 1999
    Posts
    318

    Re: edit control in a propertypage

    I do not understand. I try the solution I purposes and it works.

    Is your problem to disable the default button on pressing ENTER key ?

    If yes i try the following code when mypage has the focus and when user press ENTER key then the default button is not used because the message is not dispatched (return TRUE).


    BOOL CMySheet::PreTranslateMessage(MSG* pMsg)
    {
    if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
    if ( GetActivePage() == &MyPage )
    return TRUE;
    return CPropertySheet::PreTranslateMessage
    (pMsg);
    }




    If your problem is another one then explain it more precisely.










  5. #5
    Join Date
    May 1999
    Posts
    23

    Re: edit control in a propertypage

    Thank you eric

    that is what my problem is and solved it through your idea. Thank You for your information
    bye from Subramanian


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