Solved

MS VC++ / CControlBar object problem

Posted on 1998-10-13
6
685 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SendMessage fails while PostMessage works 2 122
multi threaded debug dll option in visual studio 2 119
Socket Programming (Unix) 8 139
C++ question 3 70
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

790 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