Hi Ananth,
I'm sorry for the typo, I meant API.
Now for the example:
'Add picturebox controls. Make them invisible or position them
outside the boundaries of your form.
'Set 'Autosize' to 'True' and put a bitmap (not an Icon) into them.
Bitmap maximum of 13X13.
In this exaple there are 3 picture boxes : imOPen, imSave ans imPrint
Also create a menu file with Open, Save and Print as submenus
'Place these Declarations in your module
Private Declare Function VarPtr Lib "VB40032.DLL" (variable As Any)
As Long
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long)
As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As
Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal
hMenu As Long, ByVal nPosition As Long, ByVal
wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked
As Long) As Long
Const MF_BYPOSITION = &H400&
'Place this code into the form load event:
Dim mHandle As Long, lRet As Long, sHandle As Long, sHandle2 As Long
mHandle = GetMenu(hwnd)
sHandle = GetSubMenu(mHandle, 0)
lRet = SetMenuItemBitmaps(sHandle, 0, MF_BYPOSITION, imOpen.Picture,
imOpen.Picture)
lRet = SetMenuItemBitmaps(sHandle, 1, MF_BYPOSITION, imSave.Picture,
imSave.Picture)
lRet = SetMenuItemBitmaps(sHandle, 3, MF_BYPOSITION,
imPrint.Picture, imPrint.Picture)
This code is for when you would have more 'main' menu's such as Edit
(with submenu Copy). Then you need
also a fourth picturebox imCopy
sHandle = GetSubMenu(mHandle, 1)
sHandle2 = GetSubMenu(sHandle, 0)
lRet = SetMenuItemBitmaps(sHandle2, 0, MF_BYPOSITION,
imCopy.Picture, imCopy.Picture)
and off you go.
There is also another method. It uses an Imagelist control. So you
do not need the picture boxes. You place the bitmap
images in this control. Here follows the code:
Private Declare Function VarPtr Lib "VB40032.DLL" (variable As Any)
As Long
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long)
As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As
Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemInfo Lib "user32"
Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As
Long, ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
hBMP As Long
End Type
Dim mii As MENUITEMINFO
Private Const MIIM_BITMAP = &H80
Private Sub Form_Load()
Dim mHandle As Long, sHandle As Long, sHandle2 As Long
Dim i As Long
' put images in menu
mHandle = GetMenu(hwnd)
sHandle = GetSubMenu(mHandle, 0)
With mii
.cbSize = Len(mii)
.fMask = MIIM_BITMAP
For i = 0 To 2
.hBMP = ImageList.ListImages(i + 1).Picture
SetMenuItemInfo sHandle, i, True, mii
Next i
End With
Please do not hesitate to contact me if you are "in trouble"
Good luck, and have fun.
Paul
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/