我正在尝试以MFC格式动态设置CPropertyPage的标题。此表单使用向导模式创建。这是我的代码。此代码编译和运行不会设置标题。如何设置向导窗口的标题?
BOOL MyForm::OnSetActive()
{
CPropertySheet* pWnd = (CPropertySheet*) GetParent();
pWnd->SetTitle(L"My Title",PSH_PROPTITLE);
return CPropertyPage::OnSetActive();
}
答案 0 :(得分:2)
尝试在事件WM_SHOWWINDOW上执行此操作。在我的代码中,它的工作方式如下:
void CPropSIni::OnShowWindow(BOOL bShow, UINT nStatus)
{
CPropertyPage::OnShowWindow(bShow, nStatus);
CNodeSheet* pSheet = (CNodeSheet*)GetParent();
if ( (bShow==TRUE) && (pSheet->IsWizard()) )
{
CString strTemp;
pSheet->GetWindowText(strTemp);
CString strCaption;
strCaption = CustomFormat(CART_CAPTION_FORMAT_ADD, 2, strTemp, pSheet->m_Name);
CPropertyPage::OnSetActive();
pSheet->SetTitle(strCaption);
}
}