vc2010中的窗口最大化问题

dhdream 2011-07-08 07:42:43
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();

vc2010中,在initinstance函数中使用如上的语句,起始窗口并没有全屏最大化;需要点击最大化按钮两次后才全屏最大化。

哪位大哥知道为什么哈?
...全文
268 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
猿创日记 2011-07-12
  • 打赏
  • 举报
回复
晕,竟然改不了颜色。

BOOL CfffApp::InitInstance()
{
/***********省略一点*******************/
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CfffDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CfffView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);


/****************这里****************************/

CleanState(_T("WorkSpace"));

/****************上面***************************/

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);


// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
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-> ShowWindow(SW_SHOWMAXMIZED);
***********************************/
m_pMainWnd->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand
return TRUE;
}


猿创日记 2011-07-12
  • 打赏
  • 举报
回复
可以试试这句。加在APP里面的IntInstance函数里面。

BOOL CfffApp::InitInstance()
{
/***********省略一点*******************/
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CfffDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CfffView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);



CleanState(_T("WorkSpace"));

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);


// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
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-> ShowWindow(SW_SHOWMAXMIZED);
***********************************/
m_pMainWnd->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand
return TRUE;
}

dhdream 2011-07-11
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 zz_lgy 的回复:]
楼主是使用了CFormView了吧,好像有最大化显示的问题, 在MainFrame里删掉注册表中的一项

AfxGetApp()->DelRegTree(hKey, "WindowPlacement");


或者最大化前

m_pMainWnd->ShowWindow(SW_NORMAL);// SW_SHOWDEFAULT
m_pMainWnd->ShowWindow(SW_S……
[/Quote]

就是CFormView,不知道为什么会出现问题。
不过您给的方法还是比较管用的,就是先出现一个窗口,接着闪屏最大化。
_free 2011-07-10
  • 打赏
  • 举报
回复
楼主是使用了CFormView了吧,好像有最大化显示的问题, 在MainFrame里删掉注册表中的一项

AfxGetApp()->DelRegTree(hKey, "WindowPlacement");


或者最大化前

m_pMainWnd->ShowWindow(SW_NORMAL);// SW_SHOWDEFAULT
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);

前者可能会造成最大化按钮或标题栏双击时界面展现的问题,需处理相应的消息

后者会造成窗口闪屏及跳动的问题
HBack 2011-07-10
  • 打赏
  • 举报
回复
我是来学习的
好像问题我还不是很清楚......悲催
kker123 2011-07-10
  • 打赏
  • 举报
回复
1,在*****App::InitInstance()里
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
后加 m_nCmdShow=SW_SHOWMAXMIZED //最大化

2,在*****App::InitInstance()里
m_pMainWnd-> ShowWindow(SW_SHOW);
改为m_pMainWnd-> ShowWindow(SW_SHOWMAXMIZED);

3,在CMainFrame::PreCreateWindow(CREATESTRUCT& cs)中
cs.style |= WS_MAXIMIZE

4,mainframe的oncreate中加入 ShowWindow(SW_MAXIMIZE);

5void CMainFrame::ActivateFrame(int nCmdShow)
{

nCmdShow = SW_MAXIMIZE;

CFrameWnd::ActivateFrame(nCmdShow);
}


试试这些方法行不?
向立天 2011-07-09
  • 打赏
  • 举报
回复
我试了一下
没问题啊
我是在创建工程是选择了最大化窗口
不过代码就是这样了
win7旗舰版+2010旗舰版
dhdream 2011-07-08
  • 打赏
  • 举报
回复
我在网上搜索了一下,和下面msdn论坛中的问题一样,可是都没有答案。

http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/7ec2424f-e787-420e-8861-7c24db051562
Eleven 2011-07-08
  • 打赏
  • 举报
回复
[Quote=引用楼主 dhdream 的回复:]
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();

vc2010中,在initinstance函数中使用如上的语句,起始窗口并没有全屏最大化;需要点击最大化按钮两次后才全屏最大化。

哪位大哥知道为什么哈?
[/Quote]
我用VS2008SP1建了一个SDI工程,试了一下没有问题~
dhdream 2011-07-08
  • 打赏
  • 举报
回复
还是不行,以前vc6中不会出现这样现象!
W1nds 2011-07-08
  • 打赏
  • 举报
回复
放到OnInitDialog中试试

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧