A DevStudio like CControlBar(2) | CodeGuru

A DevStudio like CControlBar(2)

Note: the following is a copy of the original article I wrote for Codeguru, with all amandments since added. Thank you all for your interest After spending much time looking for an authentic-looking DevStudio™-alike docking dialog bar, I found very few possible contenders. The best of which is Alger Pike’s "DevStudio-like CControlBar", which, unfortunately, fell […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 1, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Note: the following is a copy of the original article I
wrote for Codeguru, with all amandments since added. Thank
you all for your interest

After spending much time looking for an authentic-looking
DevStudio™-alike docking dialog bar, I found very few
possible contenders. The best of which is Alger Pike’s
"DevStudio-like CControlBar", which, unfortunately,
fell short at providing support for dynamically resizing the
dialog and real authentic DevStudio looks.

So, for my inspiration, I turned to the simpler resizing
ControlBar which has raised much attention on codeguru (judging
from the amount of articles here relating to it). The task at
hand was to add resizing dialog support and draw authentic
gripper controls. This was acutally quite easy. The real nasty
part was doing the calculations for the size of the client area
(this still isn’t as clean as I would like – read the code and
see). Eventually, I ended up with a simple, yet functional
DevStudio-alike dialog bar that actually took a minimal amount of
work – how great!

A great piece of functionality introduced with the
CoolDialogBar is that it takes CDialog classes in its Create
functions. That is, if you already have a killer dialog that you
wish to port to a docking dialog bar, it requires only minimal
code, as it does not have to be changed to adapt to MFC’s
CDialogBar class. Also, this means you can still have DDX support
in your dialog bars.

The create function for the CCoolDialogBar is defined as
follows:

BOOL CCoolDialogBar::Create(CWnd* pParentWnd, CDialog *pDialog,
                            CString &pTitle, UINT nID, DWORD dwStyle)

The function takes a pointer to the parent window, a pointer
to the dialog class (if you do not require a custom dialog class,
simply pass it a new CDialog item), the title of the dialog bar
(it will be shown when floating), the ID of the dialog bar, and
the dialog bar style (the CBRS_ flags, etc..).

Other than the create function, the rest of the class acts as
a normal CDialogBar.

NOTE: The one problem that re-surfaced in almost every response was that you were unable to see your
dialog controls within the bar. This problem can be avoided by creating a Dialog
resource with the “Visible” attribute set (unlike the standard CDialogBar).

Making the Floating Dialog Resizeable (Added by Rob Wolpov – thankyou!)

To make a floating dialog resizeable, add a
SetBarStyle() function call in the OnCreate() function, and specify
the CBRS_SIZE_DYNAMIC option.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...

    CString title("CoolBar Demo");
    if (!m_wndDialogBar.Create(this, &m_cDialog,title, IDD_DIALOG1))
    {
        TRACE0("Failed to create dialogbar\n");
        return -1;      // fail to create
    }

>   m_wndDialogBar.SetBarStyle(m_wndDialogBar.GetBarStyle() |
>                              CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
    ...
}

Note also that the ‘title’ CString variable was used instead of
putting the CString constructor in the Create() call. This was
done to suppress a compiler warning.

Download source – 6KB

Download demo project – 25KB

Download demo executable – 11KB

Date Posted: 8 Jul 98
Last updated: 1 Feb 98

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.