VC之基础

论坛 期权论坛     
选择匿名的用户   2021-6-2 18:04   243   0
<p> HWND类型如何转化为HANDLE类型?</p>
<p>  直接(HANDLE)hWnd就可以。 </p>
<p><span style="FONT-SIZE: 10pt; COLOR: black">窗口</span><span style="FONT-SIZE: 10pt; COLOR: black"><br></span><span style="FONT-SIZE: 10pt; COLOR: black">让窗口一启动就最大化</span><span style="FONT-SIZE: 10pt; COLOR: black"><br></span><span style="FONT-SIZE: 10pt; COLOR: black">把应用程序类(</span><span style="FONT-SIZE: 10pt; COLOR: black">CxxxApp</span><span style="FONT-SIZE: 10pt; COLOR: black">)的</span><span style="FONT-SIZE: 10pt; COLOR: black"> InitInstance() </span><span style="FONT-SIZE: 10pt; COLOR: black">函数中的</span><span style="FONT-SIZE: 10pt; COLOR: black"><br>m_pMainWnd-&gt;ShowWindow(SW_SHOW); </span><span style="FONT-SIZE: 10pt; COLOR: black">改为</span><span style="FONT-SIZE: 10pt; COLOR: black"><br>m_pMainWnd-&gt;ShowWindow(SW_SHOWMAXIMIZED);<br></span><span style="FONT-SIZE: 10pt; COLOR: black">则窗口一启动就最大化显示。</span><span style="FONT-SIZE: 10pt; COLOR: black"><br></span><span style="FONT-SIZE: 10pt; COLOR: black">如何设置窗口的初始尺寸</span><span style="FONT-SIZE: 10pt; COLOR: black"><br></span><span style="FONT-SIZE: 10pt; COLOR: black">在将应用程序类(</span><span style="FONT-SIZE: 10pt; COLOR: black">CxxAPP</span><span style="FONT-SIZE: 10pt; COLOR: black">)的</span><span style="FONT-SIZE: 10pt; COLOR: black"> InitInstance() </span><span style="FONT-SIZE: 10pt; COLOR: black">函数中加入:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br>m_pMainWnd-&gt;SetWindowPos(NULL,x,y,Width,Height,SWP_NOMOVE);<br>Width</span><span style="FONT-SIZE: 10pt; COLOR: black">为窗口宽度,</span><span style="FONT-SIZE: 10pt; COLOR: black">Height</span><span style="FONT-SIZE: 10pt; COLOR: black">为窗口高度</span><span style="FONT-SIZE: 10pt; COLOR: black"><br>SWP_NOMOVE</span><span style="FONT-SIZE: 10pt; COLOR: black">表示忽略位置</span><span style="FONT-SIZE: 10pt; COLOR: black">(x,y)</span><span style="FONT-SIZE: 10pt; COLOR: black">。</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br></span><span style="FONT-SIZE: 10pt; COLOR: black">如:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br>BOOL CDzyApp::InitInstance()<br>{<!-- --><br>  AfxEnableControlContainer();<br>  ……<br><br>  // The one and only window has been initialized, so show and update it.<br>  m_pMainWnd-&gt;SetWindowPos(NULL,0,0,750,555,SWP_NOMOVE);//</span><span style="FONT-SIZE: 10pt; COLOR: black">设置窗口的初始大小为</span><span style="FONT-SIZE: 10pt; COLOR: black">750*555<br>  m_pMainWnd-&gt;ShowWindow(SW_SHOW);<br>  m_pMainWnd-&gt;UpdateWindow();<br><br>  return TRUE;<br>}<br></span><span style="FONT-SIZE: 10pt; COLOR: black">让窗口居中显示</span><span style="FONT-SIZE: 10pt; COLOR: black"><br></span><span style="FONT-SIZE: 10pt; COLOR: black">以下两种方法可任选其一:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br></span><span style="FONT-SIZE: 10pt; COLOR: black">①在应用程序类(</span><span style="FONT-SIZE: 10pt; COLOR: black">CxxxApp</span><span style="FONT-SIZE: 10pt; COLOR: black">)的</span><span style="FONT-SIZE: 10pt; COLOR: black"> InitInstance() </span><span style="FONT-SIZE: 10pt; COLOR: black">函数中加入:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br>m_pMainWnd-&gt;CenterWindow( GetDesktopWindow() );<br><br></span><span style="FONT-SIZE: 10pt; COLOR: black">②在主框架类</span><span style="FONT-SIZE: 10pt; COLOR: black">(MainFrm.cpp)</span><span style="FONT-SIZE: 10pt; COLOR: black">的</span><span style="FONT-SIZE: 10pt; COLOR: black">OnCreate()</span><span style="FONT-SIZE: 10pt; COLOR: black">函数中加入:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br>CenterWindow( GetDesktopWindow() );<br><br></span><span style="FONT-SIZE: 10pt; COLOR: black">如:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br>int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)<br>{<!-- --><br>  if (CFrameWnd::OnCreate(lpCreateStruct) &#61;&#61; -1)<br>  return -1;<br>  ……<br><br>  // TODO: Delete these three lines if you don&#39;t want the toolbar to<br>  // be dockable<br>  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);<br>  EnableDocking(CBRS_ALIGN_ANY);<br>  DockControlBar(&amp;m_wndToolBar);<br><br>  CenterWindow( GetDesktopWindow() ); //</span><span style="FONT-SIZE: 10pt; COLOR: black">使窗口打开时处于屏幕正中</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br>  return 0;<br>}<br></span><span style="FONT-SIZE: 10pt; COLOR: black">如何修改窗口标题</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br></span><span style="FONT-SIZE: 10pt; COLOR: black">窗口标题一般形式为:文档标题</span><span style="FONT-SIZE: 10pt; COLOR: black"> - </span><span style="FONT-SIZE: 10pt; COLOR: black">程序标题</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br>1</span><span style="FONT-SIZE: 10pt; COLOR: black">、设置文档标题:</span><span style="FONT-SIZE: 10pt; COLOR: black"><br><br></span><span style="FONT-SIZE: 10pt; COLOR: black">在文档类</span><span style="FONT-SIZE: 10pt; COLOR: black">(CxxxDoc)</span><span style="FONT-SIZE: 10pt; COLOR: black">的</span><span style="FONT-SIZE: 10pt; COLOR: black">OnNewDocument()</span><span style="FONT-SIZE: 10pt; COLOR: black">函数中加入语句&#
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP