MS VC++ / CControlBar object problem

Posted on 1998-10-13
Last Modified: 2008-02-01
I have problem using CControlBar as a child of CFrameWnd. I use CFrameWnd object on my own - I do not use App wizard code whitch includes View / Document support, whitch I do not want use. I use "hand wizard" code, whitch just only create CWndApp object and on its initialization CFrameWnd object as the main application window.

All works correctly without the CControlBar object (its CControlBar and CStatusBar derived objects exactly), created as a child of the CFrameWnd object. The CControlBar object is functional expect one cosmetic mistake:

It is viewed in the level of client area of this CFrameWnd object window. Normally it is bulging, so it looks as part of the frame. (For exact imagination - the CControlBar is viewed just as a scroll bar - i do not meen the buttons of scroll bar, but the light gray part of the scroll bar).

App wizard creates code, whitch works correctly, but I can not use it as a sample, because it uses some dynamic object creation magic.

Parts of code, whitch results is this problem:

// CControlBar initialization code
int CFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)

      // T O O L  B A R  C R E A T I O N
      if (!_ToolBar.Create(this, WS_CHILD |
                WS_VISIBLE | CBRS_TOP | WS_DLGFRAME ,
             _IDW_CONTROLBAR_FIRST + 10)
           || !_ToolBar.LoadToolBar(IDR_TOOLBAR))

// CFrameWnd Initialization Code
// - parent of CControlBar object
BOOL CWndApp::InitInstance()
      _FrameMainP = new CFrameMain;
      m_pMainWnd = _FrameMainP;
      if (!_FrameMainP->Create
            "Main Framme",
            WS_OVERLAPPEDWINDOW, // dwStyle
            CFrameWnd::rectDefault,      // default rectangle
            NULL,      // parent wnd
            MAKEINTRESOURCE(IDR_MENU), // menu
            )) ASSERT(0);
Question by:buk
  • 3
  • 2

Expert Comment

ID: 1175044
Normally, you have to answer to the WM_SIZEPARENT message (sent by the frame window) to position you control bar and resize the parent client area. This may be the cause of your problem.

Author Comment

ID: 1175045
// THE TOOLBAR IS D O C K E D using this code:

Expert Comment

ID: 1175046
Where do you want it docked?
 _Toolbar.EnableDocking (CBRS_ALIGN_TOP)

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.


Author Comment

ID: 1175047
The problem is just only apearance of the docked CControlBar regardless where it is docked.

Author Comment

ID: 1175048
The problem is just only apearance of the docked CControlBar regardless where it is docked.

Accepted Solution

f4817 earned 100 total points
ID: 1175049
use RecalcLayout() function after your toolbar creation in your CFrameWnd::OnCreate

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question