SetWindowText无法改变标题怎么回事?
答案:3 悬赏:20 手机版
解决时间 2021-01-13 11:21
- 提问者网友:回忆在搜索
- 2021-01-12 12:05
SetWindowText无法改变标题怎么回事?
最佳答案
- 五星知识达人网友:末日狂欢
- 2021-01-12 13:14
在CMainFrame的PreCreatWindow中
加入:
cs.style&=~FWS_ADDTOTITLE;
cs.lpszName="哟哟哟";
加入:
cs.style&=~FWS_ADDTOTITLE;
cs.lpszName="哟哟哟";
全部回答
- 1楼网友:愁杀梦里人
- 2021-01-12 14:35
试一下
把代码加这个函数里InitInstance()
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetWindowText("VC");//加这里
你的方法不要行主要是
ProcessShellCommand(cmdInfo))这个函数调用东西太多
最后调用了这个函数改变标题
void CFrameWnd::InitialUpdateFrame(CDocument* pDoc, BOOL bMakeVisible)
{
// if the frame does not have an active view, set to first pane
CView* pView = NULL;
if (GetActiveView() == NULL)
{
CWnd* pWnd = GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE);
if (pWnd != NULL && pWnd->IsKindOf(RUNTIME_CLASS(CView)))
{
pView = (CView*)pWnd;
SetActiveView(pView, FALSE);
}
}
if (bMakeVisible)
{
// send initial update to all views (and other controls) in the frame
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
// give view a chance to save the focus (CFormView needs this)
if (pView != NULL)
pView->OnActivateFrame(WA_INACTIVE, this);
// finally, activate the frame
// (send the default show command unless the main desktop window)
int nCmdShow = -1; // default
CWinApp* pApp = AfxGetApp();
if (pApp != NULL && pApp->m_pMainWnd == this)
{
nCmdShow = pApp->m_nCmdShow; // use the parameter from WinMain
pApp->m_nCmdShow = -1; // set to default after first time
}
ActivateFrame(nCmdShow);
if (pView != NULL)
pView->OnActivateView(TRUE, pView, pView);
}
// update frame counts and frame title (may already have been visible)
if (pDoc != NULL)
pDoc->UpdateFrameCounts();
OnUpdateFrameTitle(TRUE);//这里
}
所以你无论在哪个类里改都没用
因为都会被OnUpdateFrameTitle(TRUE);//重写
你只有当窗口建立后用消息才能动态改变
你自己调试ProcessShellCommand(cmdInfo))看看
把代码加这个函数里InitInstance()
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetWindowText("VC");//加这里
你的方法不要行主要是
ProcessShellCommand(cmdInfo))这个函数调用东西太多
最后调用了这个函数改变标题
void CFrameWnd::InitialUpdateFrame(CDocument* pDoc, BOOL bMakeVisible)
{
// if the frame does not have an active view, set to first pane
CView* pView = NULL;
if (GetActiveView() == NULL)
{
CWnd* pWnd = GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE);
if (pWnd != NULL && pWnd->IsKindOf(RUNTIME_CLASS(CView)))
{
pView = (CView*)pWnd;
SetActiveView(pView, FALSE);
}
}
if (bMakeVisible)
{
// send initial update to all views (and other controls) in the frame
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
// give view a chance to save the focus (CFormView needs this)
if (pView != NULL)
pView->OnActivateFrame(WA_INACTIVE, this);
// finally, activate the frame
// (send the default show command unless the main desktop window)
int nCmdShow = -1; // default
CWinApp* pApp = AfxGetApp();
if (pApp != NULL && pApp->m_pMainWnd == this)
{
nCmdShow = pApp->m_nCmdShow; // use the parameter from WinMain
pApp->m_nCmdShow = -1; // set to default after first time
}
ActivateFrame(nCmdShow);
if (pView != NULL)
pView->OnActivateView(TRUE, pView, pView);
}
// update frame counts and frame title (may already have been visible)
if (pDoc != NULL)
pDoc->UpdateFrameCounts();
OnUpdateFrameTitle(TRUE);//这里
}
所以你无论在哪个类里改都没用
因为都会被OnUpdateFrameTitle(TRUE);//重写
你只有当窗口建立后用消息才能动态改变
你自己调试ProcessShellCommand(cmdInfo))看看
- 2楼网友:英雄的欲望
- 2021-01-12 14:09
((CMainFrame *)AfxGetApp()->m_pMainWnd)->SetWindowText("");
试试这样
试试这样
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯