?
Solved

MS VC++ / CControlBar object problem

Posted on 1998-10-13
6
Medium Priority
?
704 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 200 total points
ID: 1175049
use RecalcLayout() function after your toolbar creation in your CFrameWnd::OnCreate
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

777 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