|
-
May 23rd, 2024, 03:51 AM
#6
Thread Starter
Addicted Member
Re: Menu icon from Resource file
 Originally Posted by xiaoyao
You should upload a complete source code example project, what is MenuIconAdd?
Hi xiaoyao, thanks for your support, yes, here it is, also tried to combine a few things, but the IDE part is not working.
Code:
Public Sub MenuIconAdd(objFRM As Object, lgMenu As Long, lgSubMenu As Long, lgResId1 As Long, Optional lgResId2 As Long = 0)
Dim hMenu As Long
Dim hSubMenu As Long
Dim hBmp1 As Long
Dim hBmp2 As Long
hMenu = GetMenu(objFRM.hwnd)
hSubMenu = GetSubMenu(hMenu, lgMenu)
If App.LogMode Then ' EXE
hBmp1 = LoadImage(App.hInstance, lgResId1, IMAGE_BITMAP, 0&, 0&, LR_LOADTRANSPARENT Or LR_CREATEDIBSECTION Or LR_SHARED)
If lgResId2 > 0 Then
hBmp2 = LoadImage(App.hInstance, lgResId2, IMAGE_BITMAP, 0&, 0&, LR_LOADTRANSPARENT Or LR_CREATEDIBSECTION Or LR_SHARED)
Else
hBmp2 = hBmp1
End If
Call SetMenuItemBitmaps(hSubMenu, lgSubMenu, MF_BYPOSITION, hBmp1, hBmp2)
Else ' IDE
Static pic1 As StdPicture
Static pic2 As StdPicture
Set pic1 = LoadResPicture(lgResId1, vbResBitmap)
If lgResId2 > 0 Then
Set pic2 = LoadResPicture(lgResId2, vbResBitmap)
Else
Set pic2 = pic1
End If
Call SetMenuItemBitmaps(hSubMenu, lgSubMenu, MF_BYPOSITION, pic1.Handle, pic2.Handle)
End If
Exit Sub
End Sub
I have BITMAP's located in the Resource from 200 and ICON's from 300, they are all in 256 color (the icons too but with transparent background).
I tried IMAGE_ICON to load, but without success.
Last edited by beic; May 23rd, 2024 at 04:04 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|