 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: icons in menus Archived to Disk
I believe only bitmaps can be used in menus (you may have meant that). Icons either have strange results, crash, or just don't do anything.
|
|
14-04-2002 at 09:46 PM |
|
|
yronium Level: Moderator

 Registered: 14-04-2002 Posts: 933
|
Re: icons in menus Archived to Disk
well, yesterday was sunday, and I finally succeed to make my bitmaps work. I stored them in a .res file (as .bmps), and found a single instruction to assign them to each menu item.
but still the color problem occurs: the menu background jumps up on the white fields of the icons (and anyway melts the other colors).
I am creating an euro-converter, and the bitmaps are the flags of the twelve countries that join it. the french, italian, irish, dutch, austrian flags would have a white field, but it is covered by the menu color, like the bitmap colors were transparent. now I needed to access to some background color property of the menu bar.
do you please have any hint on it?
thank you a lot again.
____________________________
Real Programmer can count up to 1024 on his fingers
|
|
15-04-2002 at 11:46 AM |
|
|
cromo Level: Guest

|
Re: Re: icons in menus Archived to Disk
quote: yronium wrote:
well, yesterday was sunday, and I finally succeed to make my bitmaps work. I stored them in a .res file (as .bmps), and found a single instruction to assign them to each menu item.
but still the color problem occurs: the menu background jumps up on the white fields of the icons (and anyway melts the other colors).
I am creating an euro-converter, and the bitmaps are the flags of the twelve countries that join it. the french, italian, irish, dutch, austrian flags would have a white field, but it is covered by the menu color, like the bitmap colors were transparent. now I needed to access to some background color property of the menu bar.
do you please have any hint on it?
thank you a lot again.
When I had to put a bitmap, in the toolbar, the transparent color was the one in the lower right corner... may be that can help.
Greetings!
|
|
15-04-2002 at 05:41 PM |
|
|  |
|
|
yronium Level: Moderator

 Registered: 14-04-2002 Posts: 933
|
Re: icons in menus Archived to Disk
ok, I followed that link, it explains in substance the system I used already. But that way brought me to have the bitmaps in my menu appearing transparent, and that is not good to me, as I must have flags in the menu, and I need exact flag colours, expecially the flags that contain the white colour.
In that tutorial there is a link to another tutorial (http://www.vbthunder.com/source/menu/ownmenu.htm).
I followed it completely, copied the code as explained there. When I run the form, I obtained a General Protection Fault "VB6 provoked an error C0000026H in the module KERNEL32.DLL..." I get this error in my home pc and in a laptop, both with VB6 and Win98, (I can give details on this error). So at the moment I don't know if the code works.
I tried to write to the owner of the site, to reach the author, but I get no answer. I think I won't, since on the site it's written "Copyright 1997-1999" (I guess the tutorial is very old).
Is there anybody who knows how to solve this?
Can anybody try to do the tutorial and tell me if it works (and if it does, what's wrong in my pc)?
Am I asking too much?
Thank you all.
P.S. Webmaster & JLRodgers, can you took an eye on my topic? I feel it very hard to many people, and I posted so many questions but still found no solution yet. Is it a solvable prob or is it reserved only to MS Lords?
____________________________
Real Programmer can count up to 1024 on his fingers
|
|
03-05-2002 at 09:15 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: icons in menus Archived to Disk
I went to the site that you got the code from, entered it into VB.
It put the graphics next to the appropriate menus, however when the mouse was over an item, it wasn't highlighted, but it could be clicked.
You said that you got an error... Since I didn't get an error I can only assume that the code did as the person designed it.
As far as the error you're getting I'd suggest something: make sure you have Visual Basic SP5 (Service Pack 5). It may have corrected some problem that you're facing. Likewise, there may be a patch for Windows that may be the cause.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
04-05-2002 at 02:49 AM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: icons in menus Archived to Disk
The following code would require 2picture boxes, and 1 imagelist to function, see the code for the names. It also requires 2 menus, any name (first menu with 3 items, second with 1):
Form:
Private Bitmaps As New CMenuBitmap
Option Explicit
Private Sub Form_Load()
Dim tmp As String
Dim ltmp As Long
Set Bitmaps = New CMenuBitmap
' For an image list, first number is the menu number, ie file=0, edit=1
' second number is menu item 1=new, 2=spacer, 3=exit
With Bitmaps
.SetBitmap Me.hWnd, 0, 2, ImageList1.ListImages(2).Picture, ImageList1.ListImages(2).Picture
End With
' For an ressource file you'll need an array of picture boxes 1 per picture
' then load the picture into the picturebox, then use the code above with modifications
Picture1.Picture = LoadResPicture("1", 0)
Picture2.Picture = LoadResPicture("Cut", 0)
With Bitmaps
.SetBitmap Me.hWnd, 0, 0, Picture1.Picture, Picture1.Picture
.SetBitmap Me.hWnd, 1, 0, Picture2.Picture, Picture2.Picture
End With
Set Bitmaps = Nothing
End Sub
Private Sub menuFileEnvelope_Click()
' Only if you specify a different checked graphic will this make any difference
menuFileEnvelope.Checked = Not menuFileEnvelope.Checked
End Sub
In a class named "CMenuBitmap":
Private Const MF_BYPOSITION = &H400&
Private Const MF_BYCOMMAND = &H0&
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
Private Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
Option Explicit
Public Function SetBitmap(ByVal hWnd As Long, ByVal TopMenuPos As Integer, ByVal OptionMenuPos As Integer, ByVal BitMapChecked As Long, ByVal BitMapUnChecked As Long) As String
Dim lngMenuID As Long
Dim lngSubMenuID As Long
Dim tmp As String
lngMenuID = GetMenu(hWnd)
If lngMenuID > 0 Then
lngSubMenuID = GetSubMenu(lngMenuID, TopMenuPos)
If lngSubMenuID > 0 Then
If SetMenuItemBitmaps(lngSubMenuID, OptionMenuPos, MF_BYPOSITION, BitMapChecked, BitMapUnChecked) <> 1 Then
SetBitmap = "Unable to set bitmap"
End If
Else
SetBitmap = "No Sub menus"
End If
Else
SetBitmap = "No Menus"
End If
' Create buffer
tmp = Space( 128 )
GetMenuString lngSubMenuID, OptionMenuPos, tmp, 127, MF_BYPOSITION
SetBitmap = Trim(tmp)
End Function
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
04-05-2002 at 03:00 AM |
|
|
|
|
 |
 |