First, in the module project, modulecontroller. VB
This modulecontroller class has an empty method during generation.
Private sub extendtoolstrip () <br/> 'todo: add new items to the toolstrip in the shell. see the uiextensionsites collection in the workitem. <br/> '<br/> end sub
It can be seen from the name that it is an extended toolbar, because the toolbar menu of the main form of scsf is dynamically generated, so we need to implement this method when we need to have our own toolbar.
Step 1: first define several constants in commandnames. VB in the constant folder
Namespace constants <br/> ''' <summary> <br/> ''' constants for command names. <br/> ''' </Summary> <br/> public class commandnames <br/> inherits infrastructure. interface. constants. commandnames <br/> '********************************** <br/> Public const adminform as string = "Administration" <br/> '********************** * *********** <br/> Public const eventlogform as string = "Event Log" <br/> '********* * *********************** <br/> end class <br/> end namespace
Step 2: Register and run the subform function in the basic workitemcontroller.
''' <Summary> <br/> ''' registers the launch point. <br/> ''' </Summary> <br/> ''' <Param name = "text"> the text. </param> <br/> ''' <Param name = "commandname"> name of the command. </param> <br/> ''' <Param name = "icon"> the icon. </param> <br/> ''' <Param name = "hasaccess"> If set to <C> true </C> [has access]. </param> <br/> ''' <Param name = "sitename"> name of the site. </param> <br/> ''' <Param name = "toregister"> If set to <C> true </C> [To register]. </param> <br/> protected sub registerlaunchpoint (byval text as string, byval commandname as string, optional byval icon as image = nothing, optional byval hasaccess as Boolean = true, optional byval sitename as string = constants. uiextensionsitenames. modulesmenuitems, optional byval toregister as Boolean = false) <br/> dim element as toolstripmenuitem = new toolstripmenuitem () 'toolstripbutton = new toolstripbutton () <br/> if not icon is nothing then <br/> element. image = icon <br/> element. textimagerelation = textimagerelation. imagebeforetext 'textimagerelation. imageabovetext <br/> element. imagescaling = toolstripitemimagescaling. none <br/> end if <br/> element. TEXT = text <br/> element. tooltiptext = text <br/> element. enabled = hasaccess <br/> workitem. uiextensionsites (sitename ). add (element) <br/> workitem. commands (commandname ). addinvoker (element, "click") <br/> end sub
Step 3: complete the extendtoolstrip method of the modulecontroller class
Private sub extendtoolstrip () <br/> 'todo: add new items to the toolstrip in the shell. see the uiextensionsites collection in the workitem. <br/> 'see: MS-help: // Ms. VSCC. v90/MS. vsipcc. v90/MS. practices. scsf.2008apr/scsf/html/02-04-340-showing_uielements.htm <br/> 'dim user as iusersecurityservice <br/> 'registerlaunchpoint (my. resources. moduletitle, commandnames. adminform, my. resources. administrationicon, isauthorize, sitename: = uiextensionsitenames. adminmodulesmenuitems) <br/> registerlaunchpoint (my. resources. moduletitle, commandnames. adminform, my. resources. administrationicon, true, sitename: = uiextensionsitenames. adminmodulesmenuitems) <br/> registerlaunchpoint (my. resources. eventlogtitle, commandnames. eventlogform, my. resources. I _info, isauthorize, sitename: = uiextensionsitenames. adminmodulesmenuitems) <br/> end sub
In this example, uiextensionsitenames. adminmodulesmenuitems is a defined String constant.