cancel
Showing results for 
Search instead for 
Did you mean: 

Menu Item Image

Former Member
0 Kudos

I have created a new Menu item in sap B1 application for my addon using the code below

With SBO_Application

oTechDemoRoot = .Menus.Item(5).SubMenus.Add(strTechDemoRootMenu, m_Name, SAPbouiCOM.BoMenuType.mt_POPUP, 0)

oTechDemoRoot.Image = System.Windows.Forms.Application.StartupPath + "\sap.bmp" 'add subitems and submenus to customized menu root

With oTechDemoRoot

'add submenu items to addon root

oTechDemoRoot = .SubMenus.Add("TMCADDon_0", "TMC DB Access", SAPbouiCOM.BoMenuType.mt_STRING, 1)

End With

End With

The menu item and sub items are appearing, but the image is not loaded. It shows an error, Cannot Load Image File.

please help..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Here an example of adding menu:

Hope this help you.


Private Function AddMenuItems() As Boolean

    Dim b As Boolean = True

    Dim sPath As String = System.Windows.Forms.Application.StartupPath() & "\"

    Dim oMenus As SAPbouiCOM.Menus
    Dim oMenuItem As SAPbouiCOM.MenuItem

    Dim oCreationPackage As SAPbouiCOM.MenuCreationParams
    oCreationPackage = m_oSBOApp.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

    Try
	oMenuItem = m_oSBOApp.Menus.Item("43520") 'moudles'
	oMenus = oMenuItem.SubMenus
    Catch ex As Exception
	b = False
    End Try

    Try ' If the menu already exists this code will fail
	' Creation parameters
	oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP
	oCreationPackage.UniqueID = "O01_MY_MENU"
	oCreationPackage.String = "MY MENU"
	oCreationPackage.Image = sPath & "logo16x16.bmp"

	oMenus.AddEx(oCreationPackage)
    Catch ex As Exception ' Error Handling
    End Try

    Return b

End Function

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi...

try this code..

Private Sub AddMenuItem()

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

oMenuItem = SBO_Application.Menus.Item("urschoice")

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

If SBO_Application.Menus.Exists("XXXX") Then

SBO_Application.Menus.RemoveEx("XXXX")

End If

oCreationPackage.UniqueID = "XXXX"

oCreationPackage.String = "menuname"

oCreationPackage.Enabled = True

oCreationPackage.Checked = True

oCreationPackage.Position = 0

oCreationPackage.Image = SPath & "\XXX.bmp"

oMenus = oMenuItem.SubMenus

oMenus.AddEx(oCreationPackage)

LoadFromXML()

End Sub

Regards...

Billa 2007

Former Member
0 Kudos

Hi Satyapal,

objmenu.Item("Mn_Menu01_Monster").Image = System.Windows.Forms.Application.StartupPath & "/VID1.bmp"

paste this in ur main class file ie the place above where u create the tables

Mn_Menu01_Monster='insert ur menu uid'

VID1.bmp-ur image

hope it helps u

Regards

Micheal Vasanth

Former Member
0 Kudos

Hi

Check if exist image in the path: System.Windows.Forms.Application.StartupPath + "\sap.bmp"