CDockablePane 에서 버튼을 만들면 ON_BN_CLICKED 메세지 맵을 만들고 EnableWindow(TRUE) 함수를 이용해도 버튼이 활성화 되지 않는다.
버튼 활성화를 위해서는 ON_UPDATE_COMMAND_UI 메세지 맵을 만든 후 pCmdUI->Enable(TRUE)를 이용한다.
//Resource.h
#define IDC_BT_TEST 150
//FileView.h
CButton m_btnTest;
afx_msg void OnBtnTest();
afx_msg void OnUpdateButton(CCmdUI *pCmdUI);
//FileView.cpp
BEGIN_MESSAGE_MAP(CFileView, CDockablePane)
ON_BN_CLICKED(IDC_BT_TEST, OnBtnTest)
ON_UPDATE_COMMAND_UI(IDC_BT_TEST, OnUpdateButton)
END_MESSAGE_MAP()
CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
m_btnTest.Create(_T("OK"), WS_VISIBLE | WS_CHILD, rectDummy, this, IDC_BT_TEST)
m_btnTest.EnableWindow(TRUE);
}
void CFileView::OnBtnTest()
{
TRACE0("OKn");
}
void CFileView::OnUpdateButton(CCmdUI *pCmdUI)
{
pCmdUI->Enable(TRUE);
}
#define IDC_BT_TEST 150
//FileView.h
CButton m_btnTest;
afx_msg void OnBtnTest();
afx_msg void OnUpdateButton(CCmdUI *pCmdUI);
//FileView.cpp
BEGIN_MESSAGE_MAP(CFileView, CDockablePane)
ON_BN_CLICKED(IDC_BT_TEST, OnBtnTest)
ON_UPDATE_COMMAND_UI(IDC_BT_TEST, OnUpdateButton)
END_MESSAGE_MAP()
CFileView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
m_btnTest.Create(_T("OK"), WS_VISIBLE | WS_CHILD, rectDummy, this, IDC_BT_TEST)
m_btnTest.EnableWindow(TRUE);
}
void CFileView::OnBtnTest()
{
TRACE0("OKn");
}
void CFileView::OnUpdateButton(CCmdUI *pCmdUI)
{
pCmdUI->Enable(TRUE);
}