How can I call a Button code, OnButtCalc(), when the user presses enter in an EditBox?
Printable View
How can I call a Button code, OnButtCalc(), when the user presses enter in an EditBox?
I was thinking something along the lines of:
But...It's not working. I'm thinking I probably have to get the hWnd of the button?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);
}
Any ideas?
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);
}