property Menu.Picture as IPictureDisp
Retrieves or sets the background's picture.

 TypeDescription 
   IPictureDisp A Picture object being displayed on the menu's background.  

Use the Picture property to put a picture on the menu's background.  Use the PictureDisplay property to align picture on the menu's background. Use the Picture property to display a picture on the control's background. Use the BackColor property to specify the item's background color. Use the ForeColor property to specify the item's foreground color. Use the Caption property to specify the caption of the item. Use the Picture property to specify a picture on the control's background ( menu bar ). Use the PopupBackColor property to change the background color for the popup menu. 

The following VB sample assigns a picture to a submenu:

With ExMenu1(10).SubMenu
    .PictureDisplay = Tile
    .Picture = LoadPicture("c:\winnt\zapotec.bmp")
End With

The following C++ sample assigns a picture to a submenu:

IPictureDisp* pPicture = NULL;
if ( LoadPicture( "c:\\winnt\\zapotec.bmp", &pPicture ) )
{
	CMenu1 subMenu = m_menu.GetItem( COleVariant(long(10)) ).GetSubMenu();
	subMenu.SetPicture( pPicture );
	subMenu.SetPictureDisplay( 48 /*Tile*/ );
}

where the LoadPicture function gets the IPictureDisp from a file:

The following VB.NET sample assigns a picture to a submenu:

With AxExMenu1.item(10).SubMenu
    .Picture = IPDH.GetIPictureDisp(Image.FromFile("c:\winnt\zapotec.bmp"))
    .PictureDisplay = EXMENULib.PictureDisplayEnum.Tile
End With

where the IPDH class is defined like follows:

Public Class IPDH
    Inherits System.Windows.Forms.AxHost

    Sub New()
        MyBase.New("")
    End Sub

    Public Shared Function GetIPictureDisp(ByVal image As Image) As Object
        GetIPictureDisp = AxHost.GetIPictureDispFromPicture(image)
    End Function

End Class

The following C# sample assigns a picture to a submenu:

EXMENULib.Menu subMenu = axExMenu1[10].SubMenu;
subMenu.Picture = IPDH.GetIPictureDisp(Image.FromFile("c:\\winnt\\zapotec.bmp")) as stdole.IPictureDisp ;
subMenu.PictureDisplay = EXMENULib.PictureDisplayEnum.Tile;

The following VFP sample assigns a picture to a submenu:

With thisform.ExMenu1.Item(10).SubMenu
        .PictureDisplay = 48 && Tile
        .Picture = LoadPicture("c:\WinNT\Zapotec.bmp")
EndWith
 


Send comments on this topic.
© 1999-2011 Exontrol.COM, Software. All rights reserved.