Solved

MS VC++ / CControlBar object problem

Posted on 1998-10-13
6
698 Views
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))
             ASSERT(0);
      _ToolBar.SetBarStyle(_ToolBar.GetBarStyle()|
             CBRS_TOOLTIPS | CBRS_FLYBY |
             CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS |
             CBRS_FLOAT_MULTI);
      //...
}

// CFrameWnd Initialization Code
// - parent of CControlBar object
BOOL CWndApp::InitInstance()
{
      //...
      _FrameMainP = new CFrameMain;
      m_pMainWnd = _FrameMainP;
      if (!_FrameMainP->Create
            (
            AfxRegisterWndClass(CS_DBLCLKS),
            "Main Framme",
            WS_OVERLAPPEDWINDOW, // dwStyle
            CFrameWnd::rectDefault,      // default rectangle
            NULL,      // parent wnd
            MAKEINTRESOURCE(IDR_MENU), // menu
            0,
            NULL
            )) ASSERT(0);
      //...
}
0
Comment
Question by:buk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:pauloserra
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.
0
 

Author Comment

by:buk
ID: 1175045
// MORE INFO
// TOOLBAR CREATION SPECIFY
// THE TOOLBAR IS D O C K E D using this code:
_ToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&_ToolBar);
0
 
LVL 1

Expert Comment

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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Author Comment

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

Accepted Solution

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

717 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