⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple_splitter.shtml

📁 mfc资源大全包含MFC编程各个方面的源码
💻 SHTML
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Zafir Anjum">
<title>Splitter Window - General Purpose Splitter Class</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>

<h3 align="center"><font color="#AOAO99">General Purpose Splitter Class</font></h3>

<hr align="center">

<p>This article was contributed by <a href="mailto:yurongl@context.co.uk">Yurong Lin</a>.</p>

<p>&nbsp;</p>

<p>I have seen many programmers asking how to create a splitter window in a dialog box.
Unfortunately MFC does not provide a splitter control that can be directly embedded into a
dialog box. CSplitterWnd is somehow designed to be used only inside a frame window. I have
also seen a few attempts, but none is generic and easy to use.</p>

<p>The class I am presenting is designed for general purpose. The name is CSplitterBar,
the function is to provide a splitter bar that can be embedded into any kind of windows,
such as a frame, a view or a dialog box. </p>

<p>The example I am giving here is to create a CSplitterbar control in a dialog box. If
you would like to use CSplitterBar in other kinds of windows, the procedure described here
can be easily adapted.

<ol>
  <li>Firstly, declare an object of CSplitterBar in your dialog class:</li>
</ol>

<p><font face="Courier New" size="2" color="#800000">CSplitterBar m_wndSplitterBar;</font></p>

<p>2. Secondly, create the m_wndSplitterBar object in the InitDialog function:</p>

<p><font color="#800000">&nbsp;</font><font face="Courier New" size="2"></p>

<p><font color="#800000">//Create a splitter bar</font></p>

<blockquote>
  <blockquote>
    <p><font color="#800000">CRect rect(0,0,0,0);</font></p>
    <p></font><font face="Courier New" size="2" color="#800000">m_wndSplitterBar.Create(WS_CHILD|WS_BORDER|WS_DLGFRAME|WS_VISIBLE,</font><font
    color="#800000"> rect,this,999);</font><font face="Courier New" size="2"></p>
    </font><p>&nbsp;</p>
  </blockquote>
</blockquote>

<p>3. Finally, setup the windows on the left pane and right pane of the splitter bar:</p>

<blockquote>
  <blockquote>
    <font face="Courier New" size="2"><p><font color="#800000">//Insert the splitter bar
    between a tree and a list control</font></p>
  </blockquote>
</blockquote>

<p><font color="#800000">m_wndSplitterBar.SetPanes(&amp;m_wndTree,&amp;m_wndList);</font></font></p>

<p>&nbsp;</p>

<p>That is all your need to do, and let the CSplitterBar handle all of the rest. The full
source code can be downloaded from here:</p>

<p>To use CSplitterBar in your own project, you only need to include two files:
SplitterBar.h and SplitterBar.cpp.</p>

<p>Note:</p>

<p>There is also a message &quot;WM_SPLITTER_MOVED&quot; is generated by the splitter bar
whenever the control is dragged then dropped. If you want to do something special when the
splitter is repositioned, then provide a message handler for this message.</p>

<p>Download Documentation and Source <a href="simple_splitter.zip">simple_splitter.zip</a>
(48.5k)</p>

<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>&copy; 1998 Zafir Anjum</FONT>&nbsp;</CENTER>
</TD>

<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A>&nbsp;</FONT></DIV>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -