|
Image
Nov 24, 2019 9:13:20 GMT -5
Post by wexhammer on Nov 24, 2019 9:13:20 GMT -5
How would you make a bitmap button so that when you click it it doesn't have that awful negative chrome effect? In further detail, a normal button with an image on perhaps or a hover over bitmap button?
|
|
|
Image
Nov 24, 2019 10:39:18 GMT -5
Post by tsh73 on Nov 24, 2019 10:39:18 GMT -5
Don't use button at all, use picturebox and react to MouseUp event as button click? If you work on picture (make bevels in some graphic editor) it will look like button.
|
|
|
Image
Nov 24, 2019 11:01:05 GMT -5
Post by mknarr on Nov 24, 2019 11:01:05 GMT -5
I've had luck with this technique.
First change your definition from a bmpbutton to button such as
button #main.b1, "", [dosomething], UL,location,location,location,location
then add the line after it
stylebits #main.b1, _BS_BITMAP,0,0,0 "this tells the program it's going to be a bitmap button.
Then after you open the window add this line.
Call BitmapButton Hwnd(#main.b1), HBmp("bitmapname") 'This sub routine will change the button to a bitmap button.
with this code as a subroutine
sub BitmapButton hButton, hBitmap 'Replace a button with a bitmap button. CallDLL #user32, "SendMessageA", _ hButton as uLong, _ _BM_SETIMAGE as Long, _ _IMAGE_BITMAP as Long, _ hBitmap As uLong, _ result as Long end Sub
I have dozens of bitmaps in a program and none display that chrome look when you click on them
|
|
|
Image
Nov 26, 2019 11:22:58 GMT -5
Post by wexhammer on Nov 26, 2019 11:22:58 GMT -5
This worked the other day but its not working now. Whats wrong with this code because is seems perfect to me.
[WindowSetup] NOMAINWIN WindowWidth = 442 : WindowHeight = 419 UpperLeftX = INT((DisplayWidth-WindowWidth)/2) UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
[ControlSetup] Menu #main, "&File" , "E&xit", [quit] stylebits #main.button, _BS_BITMAP,0,0,0 button #main.button, "", [hi], UL, 145, 75, 55, 35
Open "Window Title" for Window as #main #main "trapclose [quit]" #main "font ms_sans_serif 10"
Call BitmapButton Hwnd(#main.button), HBmp("a.bmp") [loop] Wait
[quit] close #main : END
[hi]
wait
sub BitmapButton hButton, hBitmap CallDLL #user32, "SendMessageA", _ hButton as uLong, _ _BM_SETIMAGE as Long, _ _IMAGE_BITMAP as Long, _ hBitmap As uLong, _ result as Long end Sub
|
|
|
Image
Nov 26, 2019 11:49:29 GMT -5
Post by Rod on Nov 26, 2019 11:49:29 GMT -5
The bitmap name for hbmp() is the name you loadbmp the actual .bmp file to.
filedialog "Open bmp", "*.bmp", bmp$ loadbmp "bmp",bmp$ Call BitmapButton Hwnd(#main.button), HBmp("bmp")
|
|
|
Image
Nov 26, 2019 12:10:22 GMT -5
Post by wexhammer on Nov 26, 2019 12:10:22 GMT -5
Thanks, but from a professional stand point, i do believe having to load a bmp image into the program every time on startup is not user friendly.
i have tried another method and this isn't working either.
loadbmp "up.bmp",bmp$ Menu #main, "&File" , "E&xit", [quit] bmpbutton #main.up, "up.bmp",[bmpbutton1Click],UL, 125, 145 stylebits #main.button, _BS_BITMAP,0,0,0 button #main.button, "", [hi], UL, 145, 75, 55, 35
Open "Window Title" for Window as #main #main "trapclose [quit]" #main "font ms_sans_serif 10" #main.up "!hide"
Call BitmapButton Hwnd(#main.button), HBmp("up.bmp")
|
|
|
Post by Chris Iverson on Nov 26, 2019 13:28:58 GMT -5
You've almost got the idea. You just need to specify the path in the LOADBMP command, not the HBMP() function.
loadbmp "up","up.bmp" call BitmapButton hwnd(#main.button), hbmp("up")
|
|
|
Post by Rod on Nov 26, 2019 14:18:00 GMT -5
The devil is in the detail. You were almost right. If bmp$ had contained "a.bmp", the path to the .bmp, then you would have loaded and named a bmp resource called "a.bmp" That name is what hbmp() needed.
It is a little confusing bmp "names" are not really strings they are handle "names" that point to a resource. I would only use the . character in true path/file names when you name resources keep it simple use bmp or bmpflower so you know it is a bmp "name" and not a file path.
I think all software has to load the resources it intends to use, so its just normal to do this. You can load and delete bmp at will so you can manage the resources your program uses.
|
|
|
Image
Nov 26, 2019 14:19:51 GMT -5
Post by Carl Gundel on Nov 26, 2019 14:19:51 GMT -5
The devil is in the detail. You were almost right. If bmp$ had contained "a.bmp", the path to the .bmp, then you would have loaded and named a bmp resource called "a.bmp" That name is what hbmp() needed. It is a little confusing bmp "names" are not really strings they are handle "names" that point to a resource. I would only use the . character in true path/file names when you name resources keep it simple use bmp or bmpflower so you know it is a bmp "name" and not a file path. I think all software has to load the resources it intends to use, so its just normal to do this. Some programming systems allow you to embed things like bitmaps into the EXE or into DLLs. Perhaps I can add something like this into LB5.
|
|