Resizable Docking Window 2

Visual Studio-like dialogbar

provided by: 
Originally published at Internet.com


This article was contributed by Cristi Posea.

Features

Control bar like in DevStudio, that size both when docked and when floating.

The source code is free !

Easy to use: just derive your own control bar from CSizingControlBar and add your child controls.

Instructions

Derive a class from CSizingControlBar (you have an example in mybar.h and mybar.cpp).

Add a member variable to CMainFrame (in mainfrm.h). CMyBar m_wndMyBar;

Create the bar in CMainFrame::OnCreate(). Then set bar styles, enable it to dock... like any control bar. if (!m_wndMyBar.Create(this, CSize(200, 100), AFX_IDW_CONTROLBAR_FIRST + 32)) { TRACE0("Failed to create mybar\n"); return -1; // fail to create }

Override CMainFrame::RecalcLayout().
Note: use the base framewnd class member function, ie if you have an SDI application replace CMDIFrameWnd with CFrameWnd below. void CMainFrame::RecalcLayout(BOOL bNotify) { CMDIFrameWnd::RecalcLayout(bNotify); CMDIFrameWnd::RecalcLayout(bNotify); }

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.

Download Source 8KB
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.

Author: Cristi Posea

Read article at Internet.com site
Related Articles
Regional Articles
- Resizable Docking Window 2 Alabama
- Resizable Docking Window 2 Alaska
- Resizable Docking Window 2 Arizona
- Resizable Docking Window 2 Arkansas
- Resizable Docking Window 2 California
- Resizable Docking Window 2 Colorado
- Resizable Docking Window 2 Connecticut
- Resizable Docking Window 2 DC
- Resizable Docking Window 2 Delaware
- Resizable Docking Window 2 Florida
- Resizable Docking Window 2 Georgia
- Resizable Docking Window 2 Hawaii
- Resizable Docking Window 2 Idaho
- Resizable Docking Window 2 Illinois
- Resizable Docking Window 2 Indiana
- Resizable Docking Window 2 Iowa
- Resizable Docking Window 2 Kansas
- Resizable Docking Window 2 Kentucky
- Resizable Docking Window 2 Louisiana
- Resizable Docking Window 2 Maine
- Resizable Docking Window 2 Maryland
- Resizable Docking Window 2 Massachusetts
- Resizable Docking Window 2 Michigan
- Resizable Docking Window 2 Minnesota
- Resizable Docking Window 2 Mississippi
- Resizable Docking Window 2 Missouri
- Resizable Docking Window 2 Montana
- Resizable Docking Window 2 Nebraska
- Resizable Docking Window 2 Nevada
- Resizable Docking Window 2 New Hampshire
- Resizable Docking Window 2 New Jersey
- Resizable Docking Window 2 New Mexico
- Resizable Docking Window 2 New York
- Resizable Docking Window 2 North Carolina
- Resizable Docking Window 2 North Dakota
- Resizable Docking Window 2 Ohio
- Resizable Docking Window 2 Oklahoma
- Resizable Docking Window 2 Oregon
- Resizable Docking Window 2 Pennsylvania
- Resizable Docking Window 2 Rhode Island
- Resizable Docking Window 2 South Carolina
- Resizable Docking Window 2 South Dakota
- Resizable Docking Window 2 Tennessee
- Resizable Docking Window 2 Texas
- Resizable Docking Window 2 Utah
- Resizable Docking Window 2 Vermont
- Resizable Docking Window 2 Virginia
- Resizable Docking Window 2 Washington
- Resizable Docking Window 2 West Virginia
- Resizable Docking Window 2 Wisconsin
- Resizable Docking Window 2 Wyoming
Related Articles

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML