Use C # and VB. NET to implement VS. NET or Office XP menus
Stingy god 2001.08.18
3. "MenuItemStyle"Interfaces andVS. NETStyle menu items
ThisProjectSwitchC# Language. In my opinion,Office200Style,VS. NETDefine a unified interface (Interface), Including the imageIcon(DrawIcon), Draw segmentation (DrawSeparator), Draw a menu background (DrawBackground), Write the text of the menu item (DrawMenuText,Office2000AndVS. NETThis interface is implemented based on different situations.Drawxxx. ThenMenuItemInherit a subclass, as described in the second sectionOverridesTwo Functions of the menu item:OnMeasureItemAndOnDrawItemTo callDrawXXXFunction. Finally, I separated all the parts and placed them in. CSFile, compiled into oneVSNET. Menu. DLL, You only useUsing VSNET. Menu;Then you can use the commonMenuItemThat way,DemoIn the source code, you can also see that I have definedIconMenuItemClass, it has a method:MenuItemCreator(VSNET. Menu. IconMenuStyle sType, String sText, Bitmap bmp, System. EventHandler eh) To generate the requiredMenuItem. Originally, I wanted to use source files or upload imagesIconResources are placed in a special file, and then the class is responsible for obtaining resources from the resource file or external class.CreateMenuItem. But it's the first version. You will see that I still use the originalNew Bitmap() Method to obtain resources directly from the hard disk. When I see itShowWhen I came out, I was very happy. Then I found that there were still many improvements. I thought it would take a lot of effort to make a professional menu.
Okay, let's take a look atVS.