CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    How use SubclassDlgItem() function?

    I`m designing a dialog ,look like DOS dialog ,press RETURN ,DOWN ,UP
    arrow ,jump to the next edit control.I don`t known how complete it.
    Please help me.


  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: How use SubclassDlgItem() function?

    I did not underdstand your question, but nevertheless use SubclassDlgItem like this:

    1. First derive a class from the class of the control you want to subclass.
    2. Override some functions to do whatever you want
    3. Subclass the control in the InitDialog() like this:
    SubclassDlgItem(IDC_CONTROL, this);

    This will make the messages to be routed through your overrided functions.

    But if you need just to catch some keys if they are pressed, better try this:

    in the PreTranslateMessage() function of your dialog place similar code to the following:

    BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
    {
    if(pMsg->message == WM_KEYDOWN && GetDlgItem(IDC_CONTROL) == GetFocus())
    {
    switch(pMsg->wParam)
    {
    case VK_ESCAPE:
    case VK_RETURN:
    case VK_HOME:
    }
    }
    }

    Hope this clears a little.
    Regards,
    ric


  3. #3
    Join Date
    Jun 1999
    Posts
    2

    Thanks ric,your answer is very right for me.

    It take me for four days to resolve this problem,
    thank you again.


  4. #4
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Thanks ric,your answer is very right for me.

    Alternatively, check out Examples 5 & 14 at my web site (http://home.earthlink.net/~railro/mfc_link.html) to know how to subclass a control.

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

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