📄 docking_window.shtml.htm
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<TITLE>Doc-View - Resizable Docking Window 2</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000">
<table WIDTH="100%">
<tr WIDTH="100%">
<td><A HREF="http://209.66.99.126/cgi/ads.cgi?advert=myad2"><IMG SRC="../../209.66.99.126/advertise2.gif" tppabs="http://209.66.99.126/advertise2.gif" ALT="" BORDER=2></A><td>
</tr>
</table>
<CENTER>
<H3>
<FONT COLOR="#AOAO99">Resizable Docking Window 2</FONT></H3></CENTER>
<HR>
This article was contributed by <A HREF="mailto:cristi@gds.ro">Cristi Posea</A>.
<P><img src="docking_window.gif" tppabs="http://www.codeguru.com/doc_view/docking_window.gif">
<H4>Features</H4>
<P>Control bar like in DevStudio, that size both when docked and when floating.
<P>The source code is free !
<P>Easy to use: just derive your own control bar from CSizingControlBar and add your child controls.
<H4>Instructions</H4>
Derive a class from CSizingControlBar (you have an example in mybar.h and mybar.cpp).
<P>Add a member variable to CMainFrame (in mainfrm.h).
<PRE><TT><FONT COLOR="#990000">
CMyBar m_wndMyBar;
</FONT></TT></PRE>
<P>Create the bar in CMainFrame::OnCreate(). Then set bar styles, enable it to dock... like any control bar.
<PRE><TT><FONT COLOR="#990000">
if (!m_wndMyBar.Create(this, CSize(200, 100),
AFX_IDW_CONTROLBAR_FIRST + 32))
{
TRACE0("Failed to create mybar\n");
return -1; // fail to create
}
</FONT></TT></PRE>
<P>Override CMainFrame::RecalcLayout().
<br>Note: use the base framewnd class member function, ie if you have an SDI application replace CMDIFrameWnd with CFrameWnd below.
<PRE><TT><FONT COLOR="#990000">
void CMainFrame::RecalcLayout(BOOL bNotify)
{
CMDIFrameWnd::RecalcLayout(bNotify);
CMDIFrameWnd::RecalcLayout(bNotify);
}
</FONT></TT></PRE>
<P>Because of RecalcLayout mechanism in MFC, I had to use several tricks to improve the look of control bar. One of them is the double call to RecalcLayout() for controlbar to stretch correctly. The other is that the height of the control bar is 4 pixel larger than its DockBar when docked vertically. So take care of OnSize() member function of your derived class. An example for a control bar with one child control is CMyBar, also included.
<P><A HREF="docking_window.zip" tppabs="http://www.codeguru.com/doc_view/docking_window.zip">Download Source</A> 8KB
<br>The zip file contains the CSizingControlBar class, a sample class CMyBar derived from CSizingControlBar and the CMainFrame class from a MDI application which have a CMyBar control bar.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -