Solved

MS VC++ / CControlBar object problem

Posted on 1998-10-13
6
667 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
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:pauloserra
Comment Utility
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
Comment Utility
// 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
Comment Utility
Where do you want it docked?
Try:
 _Toolbar.EnableDocking (CBRS_ALIGN_TOP)

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

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

Author Comment

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

Accepted Solution

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now