?
Solved

CControlBar

Posted on 1997-01-06
1
Medium Priority
?
569 Views
Last Modified: 2013-11-20
I would like to derive a simple bar from CControlbar
that will be abale to dock and float and will recieve WM_PAINT but all i want it to be is grayh with out any buttons cause i want to create my own bars (for examples
the IE3.0 or the OFFICE97 bars)
0
Comment
Question by:omri
[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
1 Comment
 

Accepted Solution

by:
jrudd010197 earned 100 total points
ID: 1300094
You won't be able to use Class Wizard but you can use the generic CWnd option and then do a find/replace on CWnd with CControlBar.  Now a basic bar must handle OnUpdateCmdUI.  This is a pure virtual function.  The easiest way to handle this function is just to create an instance of CCmdUI fill in its members and call CWnd::OnCmdMsg.  Another function you need to code is the virtual function CalcFixedLayout.  This is called when the frame needs to know how much client space it has to give up so the bar will Dock.  And the last thing you need to know that isn't covered in the online help is you need to catch the message WM_SIZEPARENT.  This is a private MFC message but it is sent to all CControlBar derived classes.  It is basically just a message to tell you that the parent is sizing itself and you better be ready to have yourself sized to.  Here is how you would handle it....

LRESULT CMyBar::OnSizeParent( WPARAM wParam, LPARAM lParam )
{
AFX_SIZEPARENTPARAMS* pLayout = reinterpret_cast<AFX_SIZEPARENTPARAMS*>(lParam);

      m_cxAvailable = CRect(pLayout->rect).Width();

      return CControlBar::OnSizeParent(wParam,lParam);
}

To handle the other messages is simple.  Since it is a CWnd derived class as well...you can just use the Wizard bar or Class Wizard to add handlers for OnPaint, OnEraseBkgnd, etc.  I recommend you look through the source of CStatusBar and CToolBar when you get ready to add your own controls ( like the Rebar ).

Hope this helps...

If you want a full ( very very simple ) example let me know.  I'll post it on the web somewhere.

Justin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

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