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)
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
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.
Last edited by Mongoose_MHS; May 16th, 2024 at 11:22 AM.
Monroe High School.. GO HORNETS!
If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that
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.
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..
Last edited by Mongoose_MHS; May 16th, 2024 at 01:10 PM.
Monroe High School.. GO HORNETS!
If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that
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..
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).
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
Last edited by Mongoose_MHS; May 17th, 2024 at 05:59 PM.
Monroe High School.. GO HORNETS!
If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that
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.
Last edited by Mongoose_MHS; May 17th, 2024 at 06:32 PM.
Reason: spelling
Monroe High School.. GO HORNETS!
If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that
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!
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.
Last edited by Mongoose_MHS; May 18th, 2024 at 08:54 PM.
Monroe High School.. GO HORNETS!
If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that
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 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.