afx_msg void OnUpdateBtn(CCmdUI* pCmdUI);
ON_UPDATE_COMMAND_UI(IDC_BROWSER, &ImageInfoView::OnUpdateBtn)
void ImageInfoView::OnUpdateBtn(CCmdUI* pCmdUI)
{
pCmdUI->Enable(true);
}
WPARAM wparam = MAKEWPARAM(SB_THUMBPOSITION, pos);
pList.SendMessage(WM_VSCROLL, wparam, 0);
1、新建一个子类CMFCPropertyGridCtrlEX继承CMFCPropertyGridCtrl
2、声明和定义子属性点击事件的消息
extern UINT AFX_WM_PROPERTY_COMMAND_CLICKED;
UINT AFX_WM_PROPERTY_COMMAND_CLICKED = ::RegisterWindowMessage(_T("AFX_WM_PROPERTY_COMMAND_CLICKED"));
3、响应WM_LBUTTONUP消息
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
ON_WM_LBUTTONUP()
void CMFCPropertyGridCtrlEx::OnLButtonUp(UINT nFlags, CPoint point)
{
CMFCPropertyGridCtrl::OnLButtonUp(nFlags, point);
CMFCPropertyGridProperty* pProp = HitTest(point);
if (pProp)
{
GetOwner ()->SendMessage(AFX_WM_PROPERTY_COMMAND_CLICKED, GetDlgCtrlID (), LPARAM(pProp));
}
}
4、然后就可以像AFX_WM_PROPERTY_CHANGED事件一样监听了
ON_REGISTERED_MESSAGE(AFX_WM_PROPERTY_COMMAND_CLICKED, &ImageInfoView::OnPropertyClicked)
LRESULT ImageInfoView::OnPropertyClicked(WPARAM wParam, LPARAM lParam)
{
CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*)lParam;
if (pProp)
{
//do something
}
return 0;
}