ISDBUI::AddMenuItem: Difference between revisions

From MediaMonkey Wiki
Jump to navigation Jump to search
No edit summary
 
(updated event handler code example)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{MethodDeclaration|SDBUI|ISDBUI|Function AddMenuItem(ParentItem As ISDBMenuItem, InSection As Long, ItemOrder As Long) As ISDBMenuItem}}
{{MethodDeclaration|SDBUI|ISDBUI|Function AddMenuItem(ParentItem As [[SDBMenuItem#ISDBMenuItem_members|ISDBMenuItem]], InSection As Long, ItemOrder As Long) As [[SDBMenuItem]]}}


===Parameters===
===Parameters===


{{MethodParameters  
{{MethodParameters  
  |ParentItem |[[SDBMenuItem]] |Specifies where to add the new item, it can either be any of Menu_xxx properties or a value returned from a previous call to [[ISDBUI::AddMenuItemSub]]
  |ParentItem |[[SDBMenuItem#ISDBMenuItem_members|ISDBMenuItem]] |Specifies where to add the new item, it can either be any of Menu_xxx properties or a value returned from a previous call to [[ISDBUI::AddMenuItemSub]]
  |InSection |Long |To which section of the ParentItem to add the new item (section is a part separated by two separator items). Last section(0), The first(1), The second(2), ..., The first from bottom, i.e.the last(-1), The second from bottom(-2), ...
  |InSection |Long |To which section of the ParentItem to add the new item (section is a part separated by two separator items). Last section(0), The first(1), The second(2), ..., The first from bottom, i.e.the last(-1), The second from bottom(-2), ...
  |ItemOrder |Long |Where will the item appear within the section: The last(0), The first(1), The second(2), ..., The first from bottom i.e.the last(-1), The second from bottom (-2), ...}}
  |ItemOrder |Long |Where will the item appear within the section: The last(0), The first(1), The second(2), ..., The first from bottom i.e.the last(-1), The second from bottom (-2), ...}}
Line 14: Line 14:
===Example code===                     
===Example code===                     
<source lang="vb">
<source lang="vb">
Sub ShowStatistics(MenuItem)
  ' This is called when user clicks the "Statistics" menu item.
End Sub
' Add a submenu to the View menu...
' Add a submenu to the View menu...
Set Mnu = UI.AddMenuItemSub( UI.Menu_View, -1, 1)     ' The first item in the last section of View menu
Set Mnu = UI.AddMenuItemSub(UI.Menu_View, -1, 1) ' The first item in the last section of View menu
Mnu.Caption = "Custom items"
Mnu.Caption = "Custom items"


' ... and add Statistics item there
' ... and add Statistics item there
Set SubMnu = UI.AddMenuItem( Mnu, 0, 0)   ' Add an item to the previously created menu
Set SubMnu = UI.AddMenuItem(Mnu, 0, 0) ' Add an item to the previously created menu
SubMnu.Caption = "&Statistics"     
SubMnu.Caption = "&Statistics"     


Mnu.OnClickFunc = "ShowIt"
SubMnu.Shortcut = "Ctrl+1"
Mnu.Shortcut = "Ctrl+1"
SubMnu.IconIndex = 35
Mnu.IconIndex = 35
Script.RegisterEvent SubMnu, "OnClick", "ShowStatistics"
</source>
</source>


=== Related Topics ===  
=== Related Topics ===  


*[[ISDBUI::Menu Compendium]]
*[[ISDBUI::AddMenuItemSub]]  
*[[ISDBUI::AddMenuItemSub]]  
*[[ISDBUI::AddMenuItemSep]]  
*[[ISDBUI::AddMenuItemSep]]  


[[Category:Scripting|{{PAGENAME}}]]
[[Category:Scripting|{{PAGENAME}}]]

Latest revision as of 15:42, 23 April 2013

CoClass SDBUI, Interface ISDBUI

Function AddMenuItem(ParentItem As ISDBMenuItem, InSection As Long, ItemOrder As Long) As SDBMenuItem


Parameters

Name Type Description
ParentItem ISDBMenuItem Specifies where to add the new item, it can either be any of Menu_xxx properties or a value returned from a previous call to ISDBUI::AddMenuItemSub
InSection Long To which section of the ParentItem to add the new item (section is a part separated by two separator items). Last section(0), The first(1), The second(2), ..., The first from bottom, i.e.the last(-1), The second from bottom(-2), ...
ItemOrder Long Where will the item appear within the section: The last(0), The first(1), The second(2), ..., The first from bottom i.e.the last(-1), The second from bottom (-2), ...


Method description

AddMenuItem creates a new menu item or a toolbar item (these two are internally handled as the same).

Example code

Sub ShowStatistics(MenuItem)
  ' This is called when user clicks the "Statistics" menu item.
End Sub

' Add a submenu to the View menu...
Set Mnu = UI.AddMenuItemSub(UI.Menu_View, -1, 1) ' The first item in the last section of View menu
Mnu.Caption = "Custom items"

' ... and add Statistics item there
Set SubMnu = UI.AddMenuItem(Mnu, 0, 0) ' Add an item to the previously created menu
SubMnu.Caption = "&Statistics"     

SubMnu.Shortcut = "Ctrl+1"
SubMnu.IconIndex = 35
Script.RegisterEvent SubMnu, "OnClick", "ShowStatistics"

Related Topics