KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q105150: HOWTO: Prevent Static Splitter Bars from Tracking

Article: Q105150
Product(s): Microsoft C Compiler
Version(s): winnt:2.0,2.1,4.0,4.1,4.2,5.0
Operating System(s): 
Keyword(s): kbMFC KbUIDesign kbVC kbWndw kbGrpDSMFCATL
Last Modified: 07-MAY-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- The Microsoft Foundation Classes (MFC), used with:
   - Microsoft Visual C++ for Windows, 16-bit edition, versions 1.0, 1.5 
   - Microsoft Visual C++, 32-bit Editions, versions 2.0, 2.1, 4.0, 4.1 
- Microsoft Visual C++, 32-bit Editions, versions 4.2, 5.0 
-------------------------------------------------------------------------------

SUMMARY
=======

In addition to providing the ability to dynamically split a single view, the
CSplitterWnd class provides a convenient method of displaying two or more view
classes in a single frame. This type of splitter window is called a "static
splitter." The CSplitterWnd class contains member functions that allow the
splitter bar to be dragged by the mouse or moved using the keyboard to change
the proportionate sizes of the views (or panes, in splitter terminology) within
the frame.

Sometimes it is desirable to fix the initial position of the splitter bars and
not allow the user to move them. This can be accomplished simply by deriving a
class from CSplitterWnd and overriding several members. This method is outlined
below.

MORE INFORMATION
================

1. Use ClassWizard to create a new class named CMySplitterWnd of class type
  "generic CWnd" and change the references to CWnd in the class declaration and
  BEGIN_MESSAGE_MAP macro to CSplitterWnd.

2. Using ClassWizard, create message handlers for WM_LBUTTONDOWN, WM_LBUTTONUP,
  WM_LBUTTONDBLCLK, and WM_MOUSEMOVE. Bypass the CSplitterWnd functionality in
  each of these overrides by calling the corresponding CWnd handlers. The
  following example illustrates the WM_LBUTTONDOWN handler:

        void CMySplitterWnd::OnLButtonDown(UINT nFlags, Cpoint point)
        {
           CWnd::OnLButtonDown(nFlags, point);
        }

3. Change any embedded CSplitterWnd members of your frame class to type
  CMySplitterWnd.

4. Remove any menu items that generate a ID_WINDOW_SPLIT command (such as the
  "Split" item on the VIEWEX sample's "Window" menu). This prevents
  CView::OnSplitCmd() from being called.


Additional query words: resize

======================================================================
Keywords          : kbMFC KbUIDesign kbVC kbWndw kbGrpDSMFCATL 
Technology        : kbAudDeveloper kbMFC
Version           : winnt:2.0,2.1,4.0,4.1,4.2,5.0
Issue type        : kbhowto

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.