Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CControlBar

Posted on 1997-01-06
1
Medium Priority
?
572 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 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