MDI窗口全屏化时为何会出现一块无法控制的矩形区域?(100分)

F

flier

Unregistered / Unconfirmed
GUEST, unregistred user!
我的要求是在一个MDI CHILD窗口中使主窗口全屏化<br>目前的思路是将MainMenu, ControlBar, StatusBar<br>不显示,且直接设置窗口使之不显示标题栏<br>但这样会在全屏化后,在窗口底部出现一块不受控制的<br>矩形,我调试代码时发现,这个情况是在把menu设置为<br>nil后出现的,看了一下VCL源码也没有什么头绪,因为<br>VCL中直接调用一个API函数来重绘菜单…… :(<br>试了半天也没什么结果,干脆贴上来,哪位大侠指教一二<br><br>BTW:MDI CHILD的窗口类型设置为none时可以实现全屏,<br>但在设置回MDICHILD时出现错误,且这样设置时,再调用MDI<br>主窗口中的函数出现问题,不知是怎么回事?<br><br>我的全屏化代码片段如下<br>procedure TfrmPage.ZoomToFullScreen;<br>var<br>&nbsp; WindowStyle: Integer;<br>begin<br>&nbsp; with frmMain do<br>&nbsp; begin<br>&nbsp; &nbsp; FullScreen := not FullScreen;<br><br>&nbsp; &nbsp; WindowStyle := GetWindowLong(frmMain.Handle, GWL_STYLE);<br>&nbsp; &nbsp; if FullScreen then<br>&nbsp; &nbsp; &nbsp; WindowStyle := WindowStyle and (not WS_CAPTION)<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; WindowStyle := WindowStyle or WS_CAPTION;<br>&nbsp; &nbsp; SetWindowLong(frmMain.Handle, GWL_STYLE, WindowStyle);<br><br>&nbsp; &nbsp; if FullScreen then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Self.WindowState := wsMaximized;<br>&nbsp; &nbsp; &nbsp; WindowState &nbsp; &nbsp; &nbsp;:= wsMaximized;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; if FullScreen then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Menu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := nil;<br>&nbsp; &nbsp; &nbsp; barControl.Visible := False;<br>&nbsp; &nbsp; &nbsp; barStatus.Visible &nbsp;:= False;<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Menu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := mnuMain;<br>&nbsp; &nbsp; &nbsp; barControl.Visible := mnuToolsToolBar.Checked;<br>&nbsp; &nbsp; &nbsp; barStatus.Visible &nbsp;:= mnuToolsStatusBar.Checked;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;
 
if FullScreen then<br>&nbsp; &nbsp; &nbsp; WindowStyle := WindowStyle and (not WS_CAPTION) and (not WS_SYSMENU)<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp;......
 
把窗口设到屏幕外,不知行不?
 
我试了一下,不关menu的事,下面那个矩形边界是child最大化时height仍小于<br>mainform的height而留下的,你的那几个控件留下任何一个就会使它不出现,border设为none时,它仍存在,只不看不见.
 
不好意思,问题我刚刚已经解决了^_^<br>方法很简单,就是将<br>&nbsp; &nbsp; WindowStyle := GetWindowLong(frmMain.Handle, GWL_STYLE);<br>&nbsp; &nbsp; if FullScreen then<br>&nbsp; &nbsp; &nbsp; WindowStyle := WindowStyle and (not WS_CAPTION)<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; WindowStyle := WindowStyle or WS_CAPTION;<br>&nbsp; &nbsp; SetWindowLong(frmMain.Handle, GWL_STYLE, WindowStyle);<br>再调用一次,只不过frmMain.Handle改成Self.Handle即可
 
原来是这样.<br>你的mdiform的windowstyle是nocaption,而childform的windowstyle不是<br>nocaption,使它计算边界时产生的误差.
 
多谢各位关注捧场,既然问题已经解决,<br>那么分数还是分给大家好了<br>(昨天忘给分了^_^)
 
多人接受答案了。
 
顶部