我原来有这个代码,但现在自己对比程序,得出了这么个方法!
就是将CM10VCApp::InitInstance()中的m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED)改为这样。问题1:上面这种方法对吗?会有问题吗?问题2:不知道还有没有别的方法,可以让程序直接以最大化打开;而不是打开后再最大化?谢谢指教!
就是将CM10VCApp::InitInstance()中的m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED)改为这样。问题1:上面这种方法对吗?会有问题吗?问题2:不知道还有没有别的方法,可以让程序直接以最大化打开;而不是打开后再最大化?谢谢指教!
解决方案 »
- 求助,如何使用glut中的绘图方法?
- Edit控件高亮背景色
- 过年回家散分
- 请问有那一位知道QQ是什么语言开发的,谁有源代码或者什么工具可以反编译
- 一画图问题,在线等
- 如何启动sqlserver以及关闭和暂停?我说得的是在程序中
- 为什么静态release版本的程序在没有vc环境的机器上面也无法运行阿?
- 今天买了台asus L4000的笔记本电脑,晚上烤机器,散分.
- 初学SDK,应该看哪种书?
- 我想让我的对话框最大this->ShowWindow(SW_MAXIMIZE);实现了,但是双击标题栏就变小了,怎么办
- 把一个.EXE的文件拷到其他机子上,当双击运行它的时候,是不是可以在那台机子上注册呢?
- 在程序A中想获取当前正拥有输入焦点的记事本程序中的RichEdit控件的句柄,该怎么办?
一般的做法是在 C**App::InitInstance()中,修改成这样:
{
//...
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
//...
}
或者,还在 CMainFrame::PreCreateWindow(CREATESTRUCT& cs)中,添加:
{
//...
cs.style |= WS_MAXIMIZE;
//...
}这种做法能产生窗口最大化,但效果是显示的时候窗口从普通大小"闪"到最大化。还有的做法,是先将窗口隐藏,然后再最大化。那么怎样使窗口正常一开始出现就最大化?看看下面的流程,从 C**App::InitInstance()中的ProcessShellCommand(...)开始:
{
//...
//ProcessShellCommand中第一次显示了窗口
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
//...
}
->CWinApp::ProcessShellCommand
->AfxGetApp()->OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL)
//如果你自己处理了ID_FILE_NEW要调用CWinApp::OnFileNew()
->CWinApp::OnFileNew()
->CDocManager::OnFileNew()
->CSingleDocTemplate::OpenDocumentFile //当前文档模板初始化
->CSingleDocTemplate::CreateNewDocument //创建文档
//加载资源并创建主窗口(顺便创建视图),但没显示
->CSingleDocTemplate::CreateNewFrame
->CFrameWnd::InitialUpdateFrame
{
//...
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); //在这里第一次显示窗口
//...
}
->CFrameWnd::ActivateFrame(int nCmdShow)
// nCmdShow is the normal show mode this frame should be in
{
// translate default nCmdShow (-1)
if (nCmdShow == -1)
{
if (!IsWindowVisible())
nCmdShow = SW_SHOWNORMAL;
else if (IsIconic())
nCmdShow = SW_RESTORE;
} // bring to top before showing
BringToTop(nCmdShow); if (nCmdShow != -1)
{
// show the window as specified
ShowWindow(nCmdShow); //第一次显示窗口 // and finally, bring to top after showing
BringToTop(nCmdShow);
}
}
->***从上面可以看出,CWinApp::ProcessShellCommand函数创建了窗口并显示,这是窗口第一次显示,先于:
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
怎么解决问题? 让窗口第一次显示就最大化? CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
//在ParseCommandLine之后,ProcessShellCommand之前,添加这句!!!
m_nCmdShow = SW_SHOWMAXIMIZED;
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();问题解决