15,979
社区成员
发帖
与我相关
我的任务
分享
BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_LBUTTONDBLCLK == pMsg->message)
{
CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC1);
ASSERT(pStatic);
CRect rect;
pStatic->GetWindowRect(&rect);
if(rect.PtInRect(pMsg->pt))
{
AfxMessageBox(_T("Click!"));
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CNewStatic::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CStatic::OnLButtonDblClk(nFlags, point);
AfxMessageBox(_T("HELLO"));
}
CNewStatic m_static; // 成员变量
BOOL CXXDlg::OnInitDialog()
{
...
m_static.SubclassDlgItem(IDC_STATIC1, this);
m_static.ModifyStyle(0, SS_NOTIFY); // 或者在资源编辑器勾上Notify属性也可以
return TRUE;
}