Solved

CControlBar

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 75
How to determine file rename from EventLog ? 2 41
mapBully challenge 6 113
wordcount challenge 11 102
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

930 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

16 Experts available now in Live!

Get 1:1 Help Now