Results 1 to 3 of 3

Thread: [Resolved] MFC: EditBox and ButtonPress?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] MFC: EditBox and ButtonPress?

    How can I call a Button code, OnButtCalc(), when the user presses enter in an EditBox?
    Last edited by The Hobo; Mar 31st, 2003 at 07:51 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I was thinking something along the lines of:

    Code:
    BOOL CVGRTaxDlg::PreTranslateMessage(MSG* pMsg) {
    
        if((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)) {
            if (pMsg->lParam == IDC_EDIT_INCOME) {
                CVGRTaxDlg::OnButtCalc();
            }
    
            return TRUE;
        }
    
        return CDialog::PreTranslateMessage(pMsg);
    }
    But...It's not working. I'm thinking I probably have to get the hWnd of the button?

    Any ideas?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Figured it out:

    Code:
    BOOL CVGRTaxDlg::PreTranslateMessage(MSG* pMsg) {
    
        if((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)) {
    
            HWND item_hwnd;
    
            GetDlgItem(IDC_EDIT_INCOME, &item_hwnd);
    			
            if (pMsg->hwnd == item_hwnd) {
                OnButtCalc();
            }
        
        return CDialog::PreTranslateMessage(pMsg);
    }
    My evil laugh has a squeak in it.

    kristopherwilson.com

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