⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcmenu.shtml.htm

📁 mfc资料集合5
💻 HTM
字号:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Chris Maunder">
   <TITLE>ToolBar - Visual Studio/Office 97 style Flat Toolbar and Dockable Menu bar</TITLE>
</HEAD>


<!-- Set background properties -->
<body background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000">

<!-- A word from our sponsors... -->
<table WIDTH="100%">
<tr WIDTH="100%"><td><td></tr>
</table>

<CENTER><H3><FONT COLOR="#AOAO99">
Visual Studio/Office 97 style Flat Toolbar and Dockable Menu bar
</FONT></H3></CENTER>

<CENTER><H3><HR></H3></CENTER>

This code was contributed by <A HREF="mailto:tmh@netfusion.co.uk">Tony Hoyle</a>

<br><br><IMG SRC="VCMenu.gif" tppabs="http://www.codeguru.com/toolbar/VCMenu.gif"><A HREF="VCMenu.zip" tppabs="http://www.codeguru.com/toolbar/VCMenu.zip">Download source files and Sample project (287 Kb)</a>.

<br><br>

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

<p>This code consists of 6 classes:

<h3>CMDIMenuFrameWnd</h3>
<p>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.

<h3>CNGenericDockBar</h3>
<p>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.

<h3>CNMDIClient</h3>
<p>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!

<h3>CNGenericToolBar</h3>
<p>This is based on the code by Roger Onslow, with modifications to allow
displaying of text on the buttons, and accelerator keys.  Basically it's 
a drop in replacement for CToolBar, with a different Create function and 
a new call (SetVisualState) which switches the text/bitmaps on and off.

<h3>CNGenericMenu</h3>
<p>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.

<h3>CNGenericPopup</h3>
<p>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.

<h3>To Use:</h3>

<p><b>Note:</b> Compilation requires an up to date commctrl.h from Microsoft. 
There is one at <a href="http://premium.microsoft.com/msdn/library/sdkdoc/c622_7nzn.htm">
http://premium.microsoft.com/msdn/library/sdkdoc/c622_7nzn.htm</a>.

<ul>
<li>Derive your CMainFrame from CMDIMenuFrameWnd.
<li>Change your CToolBar definitions to CNGenericToolBar (optional, but it looks nicer).
<li>Change your CToolBar 'Create' calls to 'CreateEx' calls.
</ul>

<p>The text for the toolbar buttons is an extra 'line' in the stringtable
entry for the command ID. To add text on a button, just add a second '\n' 
followed by your chosen text:

<PRE><TT><FONT COLOR="#990000">	Open File\nOpen       
</PRE></TT></FONT>

becomes

<PRE><TT><FONT COLOR="#990000">	Open File\nOpen\n&Open
</PRE></TT></FONT>

<p>Optionally, make a call to CToolBar::SetVisualState to show/hide bitmaps
and text (you only need to call this for a single toolbar - it will be propogated to all
existing/future toolbars).

<h3>Known bugs:</h3>

<p>Doesn't always get the width of the menu correct.  This needs further overriding of 
CalcDynamicLayout (CToolBar layout code always assumes that buttons are the same 
width, which is not the case for menus).

<p>Updated 22 April 1998.
<P>
<HR>

<TABLE BORDER=0 WIDTH="100%"><TR>

<TD WIDTH="33%">
<FONT SIZE=-1><A HREF="../index.htm" tppabs="http://www.codeguru.com/">Goto HomePage</A></FONT>
</TD>

<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>&copy; 1998 Zafir Anjum</FONT>&nbsp;</CENTER>
</TD>

<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A>&nbsp;</FONT></DIV>
</TD>

</TR></TABLE>

<!-- Counter -->
<CENTER><FONT SIZE=-2>4539</FONT></CENTER>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -