📄 mrcext.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</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=genitor"><IMG SRC="../banners/genitor.gif" tppabs="http://www.codeguru.com/banners/genitor.gif" HEIGHT=60 WIDTH=468 ALT="Genitor - award-winning Object Construction Suite for C/C++ development, documentation, and maintainance" BORDER=2></A><BR><SMALL><A HREF="http://209.66.99.126/cgi/ads.cgi?advert=genitor">Click here to get a trail copy of Genitor V3.1</A></SMALL><td>
</tr>
</table>
<CENTER>
<H3>
<FONT COLOR="#AOAO99">Resizable Docking Window</FONT></H3></CENTER>
<HR>
This article was contributed by <A HREF="mailto:mrc@mfltd.co.uk">Mark Conway</A>.
<P><IMG SRC="mrc_docktest.gif" tppabs="http://www.codeguru.com/doc_view/mrc_docktest.gif" >
<B><I><FONT FACE="Arial"><P>History</P>
</B></I></FONT><FONT SIZE=2>
<P>MRCEXT was originally written towards the end of 1994. At Micro Focus, I was involved in developing a new Development Environment for COBOL (do I hear laughter ?). We were using beta copies of Visual C++ 2.0, and liked the look and feel of the sizeable dock bars. There was plenty of debate on newsgroups about how to get these dockbars, and although the guys at Microsoft kept telling people it was all done with MFC, they weren't going to tell anyone how it was done. Back in those days, MFC wasn't documented nearly half as well as it is now, and there were relatively few samples and other literature available. </P>
<P>There was a fair amount of detective work involved, and in the process I learned far more than I wanted to about the internals of MFC. The resulting of the work was an MFC extension DLL MRCEXT.DLL, that was first made publicly available in early '95. The code hasn't changed much since first written, not because it's perfect or elegant, but because it works, and if it isn't broke don't fix it. It underlies several commercial products, including Micro Focus' Net Express product (see www.microfocus.com), so I believe it to be reasonably robust.</P>
<P>I've been intending to update the external version for a while now, but have found it very difficult to justify the time - after all I get nothing for this. One of my New Year's resolutions for 1998 was to finally get round to doing it. Although there are plenty of things I wanted to add, I just can't justify the time to do them, and my main aim of this "release" is to ship bug-fixes and a version that's compatible with Visual C++ 5.0. Consequently, very little has change from previous releases. Perhaps the biggest change is that classes are now exported using the _declspec() syntax, rather than relying explicitly on the .def file. (the .DEF file was becoming a nightmare). This means that this version is NOT compatible with the original.</P>
<P>I have added a couple of new samples: DockDemo (showing a neater docking sample); and DockScribble (the MFC tutorial Scribble CView's embedded in control bars). Due to time constraints, the documentation (UserRef.doc), and the older sample (Docktest) have not been updated. However, they still provide much useful information, especially on the non-docking classes MRCEXT contains..</P>
<P>This download will provide you with more than enough to get sizeable dockbars implemented in your own applications. I will endeavor to answer any questions you have, but cannot promise to provide solutions. </P>
<P> </P>
</FONT><B><I><FONT FACE="Arial"><P>How to Use It</P>
</B></I></FONT><FONT SIZE=2><P>Using MRCEXT is fairly straightforward:</P>
<OL>
<LI>Include the headers: Add #include <mrcext.h> to stdafx.h. This has a #pragma to link in .lib automatically.</LI>
<LI>Derive your main window class (usually called CMainFrame) from CMRCMDIFrameWndSizeDock, instead of CMDIFrameWnd - general a find/replace operation on mainfrm.cpp/h is enough. </LI></OL>
<P>Any control bars which you want to be sizeable need to be derived from CMRCSizeControlBar. In a normal MFC application is it rare to derive from CControlBar directly. Normally you would be most likely to use or derive from CDialogBar. MRCEXT includes a CMRCSizeDialogBar class, that is a drop-in replacement for MFC's CDialogBar, and which also provides a style flag to permit simple linear scaling of controls on the dialog. </P>
<P>You can derive from either CMRCSizeControlBar, or CMRCSizeDialogBar. The main difference is that CMRCDialogBar creates it's controls and initial size from a dialog resource. If you prefer to create the controls yourself, and specify the initial sizes programatically, derive from CMRCSizeControlBar. If you want to use a dialog resource, use CMRCDialogBar.</P>
<P>In your derived class you will need to override the OnSizeOrDocked() virtual function.</P>
<P>This is called to notify your bar that it's size or dock status has changed. Write code here that is responsible for positioning the child controls to the new size required. You also need to include code to allow enough of a border round the control bar so that when it's docked, the user has somewhere to grab. You'll see this in </P>
<P>the samples.</P>
<P>There is also a CMRCSizeToolBar class that replaces CToolBar. This is a control bar which subclasses the toolbar common control, and provides much of the same functionality as CToolBar, and extends it to include customization. It is not 100% compatible with CToolBar, and lacks some functionality. We don't use it in our products at Micro Focus, but you may still find it useful. </P>
<P> </P>
</FONT><B><I><FONT FACE="Arial"><P>Disclaimer</P>
</B></I></FONT><FONT SIZE=2><P>This software is provided as freeware, WITHOUT WARRANTY, and WITHOUT SUPPORT. Micro Focus Inc. accepts no liability for any losses arising from use of this software. There is no guarantee of compatibility with previous or future versions of this software.</P>
</FONT><B><I><FONT FACE="Arial"><P>If you decide to use MRCEXT</P>
</B></I></FONT><FONT SIZE=2><P>You are free to use this software in your product subject to the following restrictions:</P>
<UL>
<LI>You must acknowledge Micro Focus Inc. copyright in your Banner and/or About Box. Something simple such as "Portions copyright Micro Focus Inc" is fine. </LI>
<LI>If you alter the code, please rename the .DLL that you ship - i.e. call it something else other than MRCEXT.DLL.</LI></UL>
<P>It would also be nice if you mail me and let me know you're using it.</P>
<P> </P>
</FONT><B><I><FONT FACE="Arial"><P>DockDemo Sample</P>
</B></I></FONT><FONT SIZE=2><P>The DockDemo sample shows off some of the docking features. The bar it creates are:</P>
<UL>
<LI>a fake DevStudio style Workspace window. </LI>
<LI>a CalendarBar with an OCX calendar control in it. If this doesn't work, you have a different calendar control to me. To fix this open up the sample and insert a different OCX on this dialog. The only point of this is to prove that OCX's work in CMRCSizeDialogBar's.</LI>
<LI>a sizeable bar with the Micro Focus logo on it. This is just a CMRCSizeDialogBar with the bit set so that the bar resizes as expected.</LI></UL>
<P><IMG SRC="mrc_dockdemo.gif" tppabs="http://www.codeguru.com/doc_view/mrc_dockdemo.gif" >
</FONT><B><I><FONT FACE="Arial"><P>DockTest Sample</P>
</B></I></FONT><FONT SIZE=2><P>This is the original sample I provided back with the first MRCEXT. I decided to include it here separately, as it at least shows the DIB and AVI classes in action. </P>
</FONT><B><I><FONT FACE="Arial"><P>How it works</P>
</B></I></FONT><FONT SIZE=2><P>I guess that most of you out there don't really care how the docking works, so you can skip this bit. For those who are interested, first let's look at what happens when a standard CControlBar, (such as a toolbar) is docked into a standard CFrameWnd. </P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -