Solved

CControlBar

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
Folder Comparison 12 55
sumNumber challenge 16 140
twoTwo  challenge 35 113
Capture logon name 13 106
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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