Reputation: 6370
In autohotkey, how do you remove the black button border? I just want a button without any border on it.
I've tried all these style modifiers to no avail.
gui, add, button, hwndMyButton
Control, Style, -0x0,, ahk_id %MyButton% ;remove BS_PUSHBUTTON
Control, Style, -0x1,, ahk_id %MyButton% ;remove BS_DEFPUSHBUTTON
Control, Style, +0x8000,,ahk_id %MyButton% ;add BS_FLAT
Control, Style, +0x40,, ahk_id %MyButton% ;add BS_ICON
Upvotes: 2
Views: 1180
Reputation: 6370
JoeDF has a nice example, but I didn't want to add such a big library (it does waaay more than I needed.
So, I just used a picture control.
gui, add, picture h16 w16 vMyButton gMyProcedure, icon0, mydll
And then I wrote up a teeny library called Mousey that will change the cursor into a hand so the user knows it is a button when the mouse passes over it. And it is easy to make the icon change when you click on it - so you can use this procedure to show "pressed" and "unpressed" states.
The effect is that I now have a nice little icon for a "button".
;http://ahkscript.org/boards/viewtopic.php?p=48057#p48057
#SingleInstance, On
#NoEnv
SetBatchLines, -1
#include mousey.ahk
toggle := 0
gui, add, picture, h32 vIconButton hwndIconButton gtoggleicon icon45, shell32.dll
mouseycursor := mousey_init(IconButton,"hand")
gui, show
return
toggleicon:
if(toggle){
guicontrol,,IconButton, *icon45 shell32.dll
toggle := 0
}else{
guicontrol,,IconButton, *icon28 shell32.dll
toggle := 1
}
return
guiclose:
mousey_close(mouseycursor)
exitapp
Upvotes: 3
Reputation: 5558
You can use images to fully customize your GUI. In our case, it's the buttons.
Image Buttons for AHK GUIs.
Source: https://github.com/AHK-just-me/Class_ImageButton
Forum topic: http://ahkscript.org/boards/viewtopic.php?t=1103
An example is provided here: https://github.com/AHK-just-me/Class_ImageButton/blob/master/Sources/Sample.ahk
#NoEnv
SetBatchLines, -1
#Include Class_ImageButton.ahk
; ----------------------------------------------------------------------------------------------------------------------
Gui, DummyGUI:Add, Pic, hwndHPIC, PIC1.jpg
SendMessage, 0x0173, 0, 0, , ahk_id %HPIC% ; STM_GETIMAGE
HPIC1 := ErrorLevel
GuiColor := "Blue"
Gui, Margin, 50, 20
Gui, Font, s10
Gui, Color, %GuiColor%
ImageButton.SetGuiColor(GuiColor)
Gui, Add, Button, vBT1 w200 hwndHBT1, Button 1`nLine 2
Opt1 := [0, 0x80CF0000, , "White", "H", , "Red", 4] ; normal flat background & text color
Opt2 := [ , "Red"] ; hot flat background color
Opt5 := [ , , ,"Gray"] ; defaulted text color -> animation
If !ImageButton.Create(HBT1, Opt1, Opt2, , , Opt5)
MsgBox, 0, ImageButton Error Btn1, % ImageButton.LastError
Gui, Show, , Image Buttons
Return
; ----------------------------------------------------------------------------------------------------------------------
GuiClose:
GuiEscape:
ExitApp
Upvotes: 2