Click here to Skip to main content
Licence 
First Posted 23 Feb 2004
Views 263,989
Bookmarked 113 times

Office 2003 Menus

By | 23 Feb 2004 | Article
A component to change the look of the menus to that of Office 2003

Introduction

Just with one Single Line of code, you can change the look of all Menus and Context menus of your Windows Forms Project to look just like the menus shipped with Office 2003. Also, you can add Icons to your menus with a single line of code. There is one more feature in this component, You can simple call the method End to change the menus to its original look.

Using the code

To use the Component, First, add the component to the Toolbox, and then drag it to the form, and then just call this Method:

// To start showing the Office 2003 Menus
OfficeMenus1.Start( FormName );

Also, you can change the look of the menus to its original look by calling this method:

// to change the look of the menus to its original "classic" look
OfficeMenus1.End();

Adding Icons to Menu Items is very simple, Just add an ImageList to your project, and then change the ImageList property of your OfficeMenu Component to the ImageList you wish to use, and then use this code:

// Adding a picture to your Menus
// OfficeMenus.AddPicture( MenuItem MenuItemToAddPictureTo, int ImageIndex );
OfficeMenus1.ImageList = imageList1;
OfficeMenus1.AddPicture(menuItem2, 1);

Points of Interest

I was so confused about the way i will add pictures to menus, so i decided to add a collection of type NameValueCollection, and when we call the method AddPicture it will add the Handle of the menu and the Image index to that Collection, and when we want to retrieve the image of a menu, we search this collection for the handle of the menu, if found it returns the picture, otherwise it returns null. Check the code for more information. BTW, the code is well commented.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Mohammed Halabi



Saudi Arabia Saudi Arabia

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionUpdated Code? Pinmemberkevinlkingma5:06 17 Nov '06  
GeneralGood Control: But..... PinmemberSameers (theAngrycodeR )15:02 22 Oct '06  
GeneralProblem With images in a menu PinmemberIndarjeet23:49 28 Aug '06  
GeneralThe problem about the contextmenu Pinmembersleet_t22:23 12 Dec '05  
GeneralBug Report : Menu Disappears PinmemberMrEyes13:51 27 Nov '05  
QuestionContext Menues PinmemberGolden Dragon12:24 9 Oct '05  
AnswerRe: Context Menues PinmemberJosma23:29 3 May '06  
Generali want to learn program by VC++ Pinmemberthanhvu21:39 4 Oct '05  
Questionhow can a draw a line separator? Pinmemberaxelbrian6:09 8 Sep '05  
AnswerRe: how can a draw a line separator? PinmemberThomas-H.1:34 7 Oct '05  
GeneralUsing MdiList in Menu PinmemberJK_net22:41 3 Jul '05  
GeneralShortcut Display PinmemberDarthVeda2:32 16 Jun '05  
GeneralRe: Shortcut Display PinmemberBalder1978-22:11 4 Sep '05  
Yes, I had the same problem.
 
In the DrawShortCutText method, add this line:
string shortcut= TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString((Keys)mi.Shortcut);
 
and change all occurences of mi.Shortcut.ToString() to shortcut
 
Best regards,
Balder
QuestionIs there any possibility to use more than one contextmenu per form? Pinmembertgrk5:37 7 Jun '05  
GeneralGreat control, but I have problem with ContextMenus Pinmembertgrk3:45 7 Jun '05  
GeneralRe: Great control, but I have problem with ContextMenus Pinmembertgrk4:58 7 Jun '05  
GeneralContext menu on notify icon PinmemberAlex Matthews0:01 31 May '05  
GeneralRe: Context menu on notify icon PinmemberBalder1978-22:14 4 Sep '05  
GeneralOwner Drawn dynamic content bug PinmemberJoeKau2:01 14 May '05  
GeneralRe: Owner Drawn dynamic content bug PinmemberLiosha22:43 13 Sep '05  
GeneralRe: Owner Drawn dynamic content bug PinmemberJoeKau23:07 13 Sep '05  
GeneralRe: Owner Drawn dynamic content bug PinmemberLiosha1:47 14 Sep '05  
Generalfor hotkey Pinmemberpichamp22:07 10 Mar '05  
GeneralRe: for hotkey PinmemberNguyen Le18:00 23 Mar '05  
GeneralRe: for hotkey PinmemberThomas-H.1:04 24 Mar '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120529.1 | Last Updated 24 Feb 2004
Article Copyright 2004 by Mohammed Halabi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid