Solved

CControlBar

Posted on 1997-01-06
1
549 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
1 Comment
 

Accepted Solution

by:
jrudd010197 earned 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Whole sheet autoscrub still needed 19 44
countEvens challenge 2 59
How to convert MFC::CString to UTF8 wchar_t* 10 102
Change to event 1 74
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

746 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

9 Experts available now in Live!

Get 1:1 Help Now