-
1 Attachment(s)
Menu item Bitmap Back (Mask) color
Hi there,
How could I change the Bitmap Back (Mask) color from Magenta to vbButtonFace (or "Transparent") in the Sub menu of the Menu bar?
I have a 16x16 256 color BMP image loaded into Picture1 (Scale Mode - Pixel)
Attachment 191658
Code:
Option Explicit
Private Const MF_BYPOSITION = &H400&
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 Sub Form_Load()
Dim hMenu As Long
Dim hSubMenuFile As Long
Dim hBitmap As Long
hMenu = GetMenu(Me.hwnd)
hSubMenuFile = GetSubMenu(hMenu, 0)
hBitmap = Picture1.Picture.Handle
SetMenuItemBitmaps hSubMenuFile, 0, MF_BYPOSITION, hBitmap, hBitmap
End Sub
Is there a simple in-line solution?
Thanks! ;)
-
Re: Menu item Bitmap Back (Mask) color
Why don't you edit the bitmap in Paint and color it whatever you want?
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
VanGoghGaming
Why don't you edit the bitmap in Paint and color it whatever you want?
Because the Background color of the Menu item differs in OS's e.g.: Windows 7, 8, 10, 11 (they are not the same color).
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
Post the image and i'll fix it for you as I did for the roulette thread..
here is an example.. But again, upload your image Or feel free to use mine.
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
Post the image and i'll fix it for you as I did for the roulette thread..
here is an example.. But again, upload your image Or feel free to use mine.
Attachment 191660
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
yer image was blured and chunky.. but i tried to clean it up.. Here you go.. Maybe re-create the image?
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
yer image was blured and chunky.. but i tried to clean it up.. Here you go.. Maybe re-create the image?
Yes, but I can only load BMP in 256 color.
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
Well, the only other way would be to have the bgcolor of the menu cause transparency cannot be done with .BMP
Here you go..
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
Well, the only other way would be to have the bgcolor of the menu cause transparency cannot be done with .BMP
Here you go..
That's why I asked, is there a way to do it by GetPixel, SetPixel or TransparentBlt on the fly.
-
Re: Menu item Bitmap Back (Mask) color
I have never used any of those, so I cannot answer that direct question. The way I do it is design the image and with paint and if i want an exact color I take a screen shot of what I want and take a little piece and paste into the other image and fill what I want with that color.. There is other ways I do it, but that sums it up for a small image as yours. Then if I want a transparent image, then I open Jasc paint Shop Pro and make whatever colors I want transparent and save it as a .PNG
Anyways, I hope I was able to help you.
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
I have never used any of those, so I cannot answer that direct question. The way I do it is design the image and with paint and if i want an exact color I take a screen shot of what I want and take a little piece and paste into the other image and fill what I want with that color.. There is other ways I do it, but that sums it up for a small image as yours. Then if I want a transparent image, then I open Jasc paint Shop Pro and make whatever colors I want transparent and save it as a .PNG
Anyways, I hope I was able to help you.
I already tried similar approach but is not working how it should.
Attachment 191665
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
1.) Invalid attachment - go to "Advanced" and upload the image
2.) Maybe use the image I first provided OR use another image? Try using 24bit instead of 256 as there is only 2 colors in your design OR just use a built in icon like the "Checkmark" OR the image i am proving down below
3.) You could also upload your project and I can try a little more to help you with the image
I think you're over thinking it and making it harder on yourself with this specific image..
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
1.) Invalid attachment - go to "Advanced" and upload the image
2.) Maybe use the image I first provided OR use another image? Try using 24bit instead of 256 as there is only 2 colors in your design OR just use a built in icon like the "Checkmark" OR the image i am proving down below
3.) You could also upload your project and I can try a little more to help you with the image
I think you're over thinking it and making it harder on yourself with this specific image..
Attachment 191668
-
Re: Menu item Bitmap Back (Mask) color
-
Re: Menu item Bitmap Back (Mask) color
I was loading the image from the ImageBox not from PictureBox, that was my first mistake.
Now it's working, but have a square around the menu icon.
-
Re: Menu item Bitmap Back (Mask) color
again, the last link i gave you may explain that in posts 18-21
Try it on another PC.. The results may be better.. as per those posts OR change your PC settings
I honestly think I helped as much as I could.. Good luck
-
Re: Menu item Bitmap Back (Mask) color
Take a look at this thread, maybe it does what you want.
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Eduardo-
Take a look at
this thread, maybe it does what you want.
Yes, yes, that's it, but it's an overkill for my needs! And thank you for the link! ;)
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
again, the last link i gave you may explain that in posts 18-21
Try it on another PC.. The results may be better.. as per those posts OR change your PC settings
I honestly think I helped as much as I could.. Good luck
You basically helped me a lot, thanks! ;)
Now I just need to decide what standard back color should I use, current is RGB(240, 240, 240).
How I see Windows 11 uses RGB(249, 249, 249) for the menu, maybe I would need to use something between, like RGB(245, 245, 245)?, however RGB(240, 240, 240) quite good looking, now there is the part if someone uses different Windows Style!
The default style matches for Windows 7, 8, 10 (tested in VirtualBox).
-
1 Attachment(s)
Re: Menu item Bitmap Back (Mask) color
YW, All I can say is use a color picker.. The best one I found is "COLOR CODER", the code is free somewhere but I do not know the link but has been mention on here before.. Since uploading a zip with a .EXE is against the rules I can't upload it.. However I can make a zip and give you a link to the zip in a PM.. If i helped you, please add to my reputation as I just learned about that on here.
Someone on here definately knows the app or the link to it.. You can also just get the bg backcolor from a form's bgcolor.. no need for a color picker at all
-
Re: Menu item Bitmap Back (Mask) color
Personally, I think there should be a "Tool Section" on here and that is one that definately needs to be on it.. However, that's just MY opinion. They don't want to or can't change anything on here as I can see.. I've seen a lot of suggesstions on here but none implimented. I may be new on here, but I do some searching on here.
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
YW, All I can say is use a color picker.. The best one I found is "COLOR CODER", the code is free somewhere but I do not know the link but has been mention on here before.. Since uploading a zip with a .EXE is against the rules I can't upload it.. However I can make a zip and give you a link to the zip in a PM.. If i helped you, please add to my reputation as I just learned about that on here.
Someone on here definately knows the app or the link to it.. You can also just get the bg backcolor from a form's bgcolor.. no need for a color picker at all
Would be nice, but cant send you PM for some reason, if you can upload it somewhere and share the link here. Thanks! ;)
-
Re: Menu item Bitmap Back (Mask) color
I cannot post the link in the forum as it is against the rules, but I have sent you the link in a PM as YOU REQUESTED it..
*I did find the actual source code to it.. but you don't need that.. Just the actual app so that's what I gave you that you requested.
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
Mongoose_MHS
I cannot post the link in the forum as it is against the rules, but I have sent you the link in a PM as YOU REQUESTED it..
*I did find the actual source code to it.. but you don't need that.. Just the actual app so that's what I gave you that you requested.
Thanks, I got it, is it VB source? because I would add a Manifest to it to be nicer! ;)
-
Re: Menu item Bitmap Back (Mask) color
yes it is a vb source code.. but again, I think you just need the app as it does have the VBHEX code for the color choices you need and want with capture color.. Work on yer own project with the tools one provides you, nevermind enhancing something else that works perfectly fine is my opinon. Finish 1 project before starting another, that's how one gets lost and overwhelmed.. I think you have enough issues working on YOUR own project than focus on someone else's work.. Stay focused on YOUR project goals.
Their app is finished and works perfectly fine as is.. Does yours? No, so.. Finish yer own project before trying to "enhance" theirs.. get the point? You asked asked for help on YOUR project.. So, finish yours first. I'm not trying to be rude but rather straight to the point basically.
-
Re: Menu item Bitmap Back (Mask) color
-
Re: Menu item Bitmap Back (Mask) color
Thanks for that, but I'm seeking for simpler solution "if there is", without SubClassing or GDI+
-
Re: Menu item Bitmap Back (Mask) color
You'd better use transparent PNG images or ico resources, and then you can add different colors to them in memory to output new images.
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
xiaoyao
You'd better use transparent PNG images or ico resources, and then you can add different colors to them in memory to output new images.
I know how to implement PNG and ICO files into the resource file, but how could I change the colors on the fly?
-
Re: Menu item Bitmap Back (Mask) color
I always used to use TransparentBlt and it worked fine I used to use the pixel background color as 255,0,255, I tryed setting your original image to transpaent in a image editor and noticed there was still a little pink around the image. have you tryed a gif file. or what else you chould do it look at the first pixel and replace all that color with button face but I duno why TransparentBlt won't work. I wish I still has VB6 I know use C# so I can only guess I don't think my old VB6 will install anymore.
-
Re: Menu item Bitmap Back (Mask) color
Quote:
Originally Posted by
BenJones
I always used to use TransparentBlt and it worked fine I used to use the pixel background color as 255,0,255, I tryed setting your original image to transpaent in a image editor and noticed there was still a little pink around the image. have you tryed a gif file. or what else you chould do it look at the first pixel and replace all that color with button face but I duno why TransparentBlt won't work. I wish I still has VB6 I know use C# so I can only guess I don't think my old VB6 will install anymore.
I did try something like this, but for some reason it wont change nothing:
Code:
Private Declare Function TransparentBlt Lib "msimg32.dll" ( _
ByVal hdcDest As Long, _
ByVal nXOriginDest As Long, _
ByVal nYOriginDest As Long, _
ByVal nWidthDest As Long, _
ByVal nHeightDest As Long, _
ByVal hdcSrc As Long, _
ByVal nXOriginSrc As Long, _
ByVal nYOriginSrc As Long, _
ByVal nWidthSrc As Long, _
ByVal nHeightSrc As Long, _
ByVal crTransparent As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Sub SetTransparentBackground(picBox As PictureBox, transparentColor As Long)
Dim hdcDest As Long
Dim hdcSrc As Long
Dim bmpWidth As Long
Dim bmpHeight As Long
' Get the device context (DC) of the destination PictureBox
hdcDest = picBox.hdc
' Create a memory DC for the source bitmap
hdcSrc = CreateCompatibleDC(hdcDest)
' Select the bitmap into the memory DC
Dim hOldBmp As Long
hOldBmp = SelectObject(hdcSrc, picBox.Picture.Handle)
' Get the dimensions of the bitmap
bmpWidth = picBox.ScaleWidth
bmpHeight = picBox.ScaleHeight
' Perform the transparent blit
TransparentBlt hdcDest, 0, 0, bmpWidth, bmpHeight, _
hdcSrc, 0, 0, bmpWidth, bmpHeight, transparentColor
' Clean up
SelectObject hdcSrc, hOldBmp
DeleteDC hdcSrc
End Sub
Also I tried to change the background color with "BitBlt", but again I got an empty Picturebox.
I just got from Windows 7 to 10 and it's working almost fine.