如何让单文档窗口初始化时最大化?

guanxg 2003-03-18 08:32:00
我要求我的单文档的窗口在初始化时要最大化,我在
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)函数中加了如下代码:
cs.style = WS_OVERLAPPEDWINDOW | WS_MAXIMIZE;
也试过cs.style = cs.style | WS_MAXIMIZE;
都不可以。
我记得可以通过设置cs.style达到要求,而且不是通过修改cs.cx,cs.cy,但是忘了怎么弄了。请各位帮忙!
...全文
591 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cline 2003-03-18
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1320/1320063.xml?temp=.1480524
fingerfox 2003-03-18
  • 打赏
  • 举报
回复
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.x = 0;
cs.y = 0;
cs.cx = GetSystemMetrics(SM_CXSCREEN);
cs.cy = GetSystemMetrics(SM_CYSCREEN);
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return TRUE;
}
godsmile 2003-03-18
  • 打赏
  • 举报
回复
YourApp::OnInitialUpdate最后加上

m_pMainWnd->ShowWindow(SW_MAXIMIZE);
fingerfox 2003-03-18
  • 打赏
  • 举报
回复
BOOL CPracticeApp::InitInstance()
{
AfxEnableControlContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));

LoadStdProfileSettings(); // Load standard INI file options (including MRU)

// 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(CPracticeDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CPracticeView));
AddDocTemplate(pDocTemplate);

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

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;

// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);//在这里改个标志就OK了。:)
m_pMainWnd->UpdateWindow();

return TRUE;
}
wangxinjing 2003-03-18
  • 打赏
  • 举报
回复
up
whulz 2003-03-18
  • 打赏
  • 举报
回复
先说窗口。
在 InitStance 函数中设定 m_nCmdShow的取值.
m_nCmdShow=SW_SHOWMAXMIZED //最大化
m_nCmdShow=SW_SHOWMINMIZED //最小化
m_nCmdShow=SW_SHOWNORMAL //正常方式

MDI窗口:
如果是创建新的应用程序,可以用MFC AppWizard 的Advanced 按钮并在MDI子窗口风格组中检测最大化或最小化还可以重载 MDI Window 的PreCreateWindow函数,设置WS_MAXMIZE or WS_MINMIZE

如果从 CMDIChildWnd派生,调用 OnInitialUpdate函数中的 CWnd::Show Window来指定 MDI Child Window的风格

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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