📄 splittertog.shtml
字号:
<HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="Author" CONTENT="Guy Gascoigne - Piggford"> <TITLE>Splitter Windows – Toggling the Splitter Orientation</TITLE></HEAD><body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000" bgproperties="fixed"><table WIDTH="100%"><tr WIDTH="100%"><td align=center><!--#exec cgi="/cgi/ads.cgi"--><td></tr></table><CENTER><H3><FONT COLOR="#AOAO99">Splitter Windows – Toggling the Splitter Orientation</FONT></H3></CENTER><CENTER><H3><HR></H3></CENTER><p>This article was contributed by <a href="mailto:guy@wyrdrune.com">Guy Gascoigne -Piggford</a></p><p>This is a pair of classes that will allow you to give the user control over theorientation of the splitter in a static splitter window.</p><p>The first is <tt>CTogSplitterWnd</tt>, a <tt>CSplitterWnd</tt> that contains supportfor actually toggling the splitter bar. The second, <tt>CSplitFrame</tt>, is a <tt>CMDIChildWnd</tt>(though changing this to be any other <tt>CFrameWnd</tt> shouldn’t be hard).</p><p>The <tt>CMDIChildWnd</tt> derived class provides support for various message handlersto allow the user to get at these functions as well as providing support for closingeither pane of the view. It does this by resizing the splitter rather than completelyhiding the view, for my application this was more appropriate.</p><p>The full code is in the <a href="SplitterTog_source.zip">zip file</a>, but here are a fewcomments about the code.</p><p>The actual toggle function is:</p><pre><tt><font COLOR="#990000">void CTogSplitterWnd::Toggle(){ if ( BarIsHorizontal() ) { SetWindowLong( GetPane( 1, 0 )->m_hWnd, GWL_ID, AFX_IDW_PANE_FIRST + 1 ); m_nRows = 1; m_nCols = 2; } else { SetWindowLong( GetPane( 0, 1 )->m_hWnd, GWL_ID, AFX_IDW_PANE_FIRST + 16 ); m_nRows = 2; m_nCols = 1; }}</font></tt></pre><p>It turns out to be fairly simple, though it took some rooting around in the MFC sourceto work out how to do it. Whilst I’m sure that this is undocumented, this code isbasically the same as the version I wrote for MFC 1.5 many moons ago (<tt>SetWindowWord</tt>became <tt>SetWindowLong</tt> if I remember correctly).</p><p>There is certainly more code to <tt>CSplitFrame</tt> since it has to store the locationof the splitter bar so that it restores back to its last location. It also depends uponthe definition of a number of command IDs that are in the sample resource file.</p></body></html><P>Posted on: April 10, 98.<P><HR><TABLE BORDER=0 WIDTH="100%" ><TR><TD WIDTH="33%"><FONT SIZE=-1><A HREF="http://www.codeguru.com">Goto HomePage</A></FONT></TD><TD WIDTH="33%"> <CENTER><FONT SIZE=-2>© 1998 Zafir Anjum</FONT> </CENTER></TD><TD WIDTH="34%"><DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A> </FONT></DIV></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -