Visual Studio/Office 97 style Flat Toolbar and Dockable Menu bar



Download source files and Sample project (287 Kb).

This is a menu/toolbar/dockbar combination which is as close to the VC5/Office style as I could get.

This code consists of 9 classes:

CNGenericDockBar

The standard CDockBar overlaps the toolbars by a couple of pixels, which is undesirable if you want a '3d' look as we do. This is just a simple hack to remove the overlap on our toolbars.

CNGenericMenu

This is the draggable menu. It creates a toolbar with text items only and TBSTYLE_DROPDOWN style. It attempts to emulate the operation of a VC/Office menu as accurately as possible. When a button is clicked, the menu creates a window of type CNGenericPopup, which draws the menu. A single menu is created by the frame window class.

CNGenericPopup

This draws a standard popup menu, but passes keypresses (left/right arrow mainly) to the owner toolbar. At present it doesn't put the icons on the left as in VC5, but this should be trivial to implement. It uses a standard CMenu object, walks each menu item and draws it. A current limitation of this implementation is that it doesn't support submenus.

CNGenericToolBar

This is based on the code by Roger Onslow, with modifications to allow displaying of text on the buttons, and accelerator keys. This works as a drop in replacement for CToolBar. Functions:

	BOOL CreateEx(CWnd* pParentWnd, DWORD dwExStyle = TBSTYLE_FLAT | TBSTYLE_TRANSPARENT,
	DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_SIZE_DYNAMIC,
	UINT nID = AFX_IDW_TOOLBAR, LPCTSTR szTitle = NULL)

Extended create function.

	BOOL SetVisualState(BOOL bButtons, BOOL bText)

Calling CNGenericToolBar::SetVisualState() allows you to set how toolbars are shown (with/without bitmaps or text). It is usual to do this on your CMainFrame::OnCreate.


	BOOL GetVisualState(BOOL bText)                   Return visibility of text or bitmaps on toolbars.
	BOOL GenericToolBarModifyStyle(DWORD dwRemove, 
	                               DWORD dwAdd)       Adds/removes extended toolbar styles
	                NGTB_NO_SYSMENU                   (Override system menu on undocked toolbars)
	DWORD GetGenericToolBarStyle()                    Returns current extended toolbar style

CNMDIClient

A quick hack to handle the change of menu when a document is opened/closed. If anyone has a better way to do this I'd be glad to hear it!

CNMDIGenericMenu

Subclass of CNGenericMenu with an added function to subclass the MDIClient for MDI apps.

CNMDIMenuFrameWnd

Overrides necessary parts of CMDIFrameWnd, to allow proper hotkey operation of the menu/toolbar and to replace the CDockBar for the frame. Fairly trivial to use - just derive your CMainFrame from this & the menus work automatically.

CNMiniDockFrameWnd

Implements extended style NTGB_NOSYSMENU in toolbar styles (see CNGenericToolBar)

CNSDIMenuFrameWnd

Overrides necessary parts of CFrameWnd, to allow proper hotkey operation of the menu/toolbar and to replace the CDockBar for the frame.

Usage:

Requirements:
VC++5 with service pack 3.
commctrl.dll 4.71 or above.

Simple usage:

Create an MDI or SDI app. Add the following to the end of your stdafx.h


#define AUTO_SUBCLASS
#include "NGToolbar.h"

Complex(!) usage:

Derive your main frame from CNMDIFrameWnd or CNSDIFrameWnd Use CNGenericToolBar instead of CToolBar You can set the text that appears on the toolbar buttons by putting a third 'line' in its associated text (eg. xxx\nyyyy\nzzz). To set the startup state of a toolbar call CNGenericToolBar::SetVisualState.

Rebuilding NGTLB10x.DLL:

Requirements:
VC++5 with service pack 3.
commctrl.dll 4.71 or above.
Up to date commctrl.h

Build will create NGTLB10R.DLL for release and NGTLB10D.DLL for debug. Library inclusion is automatic (see NGToolbar.h)

Note: Compilation requires an up to date commctrl.h from Microsoft. There is one at http://premium.microsoft.com/msdn/library/sdkdoc/c622_7nzn.htm.

Updated 5 May 1998.



Comments

  • Hoofdtelefoon isnot slechts een hoofdtelefoon, is een venster op de wereld te zien

    Posted by mrswanzi on 06/05/2013 11:16pm

    [url=http://monsterkoptelefoon.npage.de/]beats by dre kopen[/url] Naast dat je je muziek wireless kunt beluisteren via bluetooth kun je er ook altijd nog voor kiezen om gewoon de meegeleverde kabel te gebruiken. Bijvoorbeeld wanneer je via een apparaat luisterd wat geen bluetooth ondersteund. Of als dat batterijen voor de bluetooth funcie leeg zijn (deze gaan ongeveer 10 uur lang mee).De komende de Monster Beats Dr Dre urBeats koptelefoon [url=http://koptelefoon-monsterbeats.tumblr.com/]beats by dre[/url] Beats By Dre Kopen doe je bij een geautoriseerde dealer. Bij een geautoriseerde dealer weer je zeker dat je een originele beats by dre koopt. Tevens heeft het kopen bij een geautoriseerde dealer het voordeel dat je ook weet dat je garantie goed zit. De dealer handelt samen met jouw garantiekwesties af. Onofficiele gaan dit soort dingen het liefst uit de weg. [url=http://koptelefoon-monsterbeats.weebly.com/]beats by dre kopen[/url] Beleef nu echt de muziek zoals die bedoeld is met de Beats by Dr Dre Studio koptelefoon, Beats by Dr Dre Studio de hoge kwaliteit koptelefoon gemaakt door de top arties Dr Dre. Veel mensen zijn aan slecht geluids kwaliteit gewent, dat ik ook niet zo gek. Al die lage kwaliteit speakers, oordopjes en koptelefoons die je overal tegen komt¡­ mensen moesten eens weten wat ze missen¡­ Als je eenmaal aan de kwaliteit standaard van deze koptelefoon gewent bent wil je niet meer anders!

    Reply
  • menu _ save _ open

    Posted by Legacy on 11/05/2003 12:00am

    Originally posted by: Hanhlona

    assume i create a project in SDI, when i run my program, how can i save the data that the user input in it and how can i open the file i saved?
    Please help me
    Thank you

    Reply
  • Problems with menues

    Posted by Legacy on 03/20/2002 12:00am

    Originally posted by: Frog

    Is there a fix for the problems with vertikal docked menues? If the menu is vertikal docked the menue items get lost, because they were placed like horizontal docked. And there is a second problem. The menue bar has a close SysIcon in the caption bar. If you close the menue you will never get it!

    Reply
  • Vc6.0 bugs fix. (Release version for the toolbar)

    Posted by Legacy on 07/09/2001 12:00am

    Originally posted by: taobell

    When you build release version for the toolbar.
    
    you may get four errors.
    undefined TB_SETINSERTMARKCOLOR
    undefined TB_GETINSERTMARKCOLOR
    undefined TVM_SETINSERTMARKCOLOR
    undefined TVM_GETINSERTMARKCOLOR

    Add follows to Afxcmn.inl(vc98\mfc\include)
    //======================
    #define TB_SETINSERTMARKCOLOR (WM_USER + 88)
    #define TB_GETINSERTMARKCOLOR (WM_USER + 89)
    #if (_WIN32_IE >= 0x0400)
    #define TVM_SETINSERTMARKCOLOR (TV_FIRST + 37)
    #define TreeView_SetInsertMarkColor(hwnd, clr) \
    (COLORREF)SNDMSG((hwnd), TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr)
    #define TVM_GETINSERTMARKCOLOR (TV_FIRST + 38)
    #define TreeView_GetInsertMarkColor(hwnd) \
    (COLORREF)SNDMSG((hwnd), TVM_GETINSERTMARKCOLOR, 0, 0)
    #endif // (_WIN32_IE >= 0x0400)
    //======================

    It is not a very clever method.but it works..;)

    Reply
  • Open problems

    Posted by Legacy on 03/28/2001 12:00am

    Originally posted by: Israel Rosas Hernandez

    I downloaded the Project but I can not open it. I have Visual C++ 6.0. Can you sende me a copy. I think that maybe the file is corrupted.
    
    

    Thanks

    Reply
  • Doesn't supply keyboard

    Posted by Legacy on 08/21/2000 12:00am

    Originally posted by: SnowFei

    This menu in Lib doesn't supply keyboard.
    1.when u push the ALT key down and up,the menu doesn't emboss.
    2.when u push the ALT_F key down and up,u can't cancel the drop menu with ESC key,ALT key and mouse event.
    3.this time u cann't select the other submenu and the NUM,CAP,SCR in statubar don't work,too.
    Sorry, i am not good at English.
    i hope you can know my means!
    thanks!

    Reply
  • Problem with *! menus

    Posted by Legacy on 05/10/2000 12:00am

    Originally posted by: hugh

    I have a number of 'top level' menus, ie menus that directly lauch a command, rather than a sub menu.
    It appears that these classes don't recognise this case. I cannot figure out how, or where to intercept it. Can anyone help please?

    Reply
  • rebuild in VC++6

    Posted by Legacy on 04/04/2000 12:00am

    Originally posted by: Frank

    I try to rebuild the dll in release version but i have some errors like this. 
    
    E:\Visual Studio\VC98\MFC\INCLUDE\afxcmn.inl(326) : error C2065: 'TVM_GETINSERTMARKCOLOR' : undeclared identifier

    The same problem appears when i want to rebuild the client project in release version

    Please, help me

    Frank

    Reply
  • loading icons from a resource ?

    Posted by Legacy on 08/30/1999 12:00am

    Originally posted by: rinix

    Very nice work !
    and I'll use the auto-subclassing feature for my future custom controls

    Just one question :
    How to load the icons from a resource (from the toolbar resource or a resource-only dll with icons or a bitmap) ?

    Thanks.

    Reply
  • Bugs with VC 6.0 (2)

    Posted by Legacy on 07/28/1999 12:00am

    Originally posted by: Viktor

    I've got similar problems trying to work with Your sample projects in VC 6.0. It's really good idea to make samples easier (more understandable I mean).

    Thank You.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • QA teams don't have time to test everything yet they can't afford to ship buggy code. Learn how Coverity can help organizations shrink their testing cycles and reduce regression risk by focusing their manual and automated testing based on the impact of change.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds