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
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?
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); }
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); }
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); }
Forum Rules