一个CComboBox控件问题
qingz 2004-12-20 03:02:49 BOOL CZpInfo::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
HWND hwnd = GetDlgItem(IDC_CMB_J)->GetSafeHwnd ();//其中IDC_CMB_J 是CComboBox控件ID
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB
&& pMsg->hwnd == hwnd){
MessageBox("aa");
return TRUE;
}
::ShowWindow (hwnd, SW_HIDE); //此句可正常执行
return CDialog::PreTranslateMessage(pMsg);
}
//
我想通过 if 中的语句来使 在CComboBox控件中按TAB键显示一个MessageBox,但不行,而之后的ShowWindow ()语句却可使该控件隐藏,不明白为什么,不过原因应该是 pMsg->hwnd != hwnd,但不知为什么?
如果用的是CComboBoxEx控件,则可通过
hwnd = (CComboBoxEX*)GetDlgItem(IDC_CMB_J))->GetEditCtrl()->GetSafeHwnd()来完成所需功能
但CComboBox没有GetEditCtrl()函数,望高手能指点一下为什么为这样!