【问题标题】:How to remove button border style?如何删除按钮边框样式?
【发布时间】:2015-09-01 18:46:36
【问题描述】:

在自动热键中,如何去除黑色按钮边框?我只想要一个没有任何边框的按钮。

我尝试了所有这些样式修饰符都无济于事。

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

【问题讨论】:

  • 如果这些都不起作用...您还不如使用图像按钮...:p
  • 谢谢,JoeDF。你的光临让我感到非常荣幸。
  • @JoeDF 如何制作“图像”按钮?只需使用picture 控件?
  • 谢谢 :) 我将使用“图片按钮”发布答案。

标签: button styles autohotkey


【解决方案1】:

您可以使用图像来完全自定义您的 GUI。在我们的例子中,它是按钮。

[类] 图像按钮

AHK GUI 的图像按钮。

来源:https://github.com/AHK-just-me/Class_ImageButton
论坛主题:http://ahkscript.org/boards/viewtopic.php?t=1103
此处提供了一个示例: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

【讨论】:

    【解决方案2】:

    JoeDF 有一个很好的例子,但我不想添加这么大的库(它确实超出了我的需要。

    所以,我只是使用了一个图片控件。

    gui, add, picture h16 w16 vMyButton gMyProcedure, icon0, mydll
    

    然后我写了一个很小的library called Mousey,它将光标变成一只手,这样当鼠标经过它时用户就知道它是一个按钮。当你点击它时,它很容易改变图标 - 所以你可以使用这个过程来显示“按下”和“未按下”状态。

    效果是我现在有了一个漂亮的“按钮”小图标。

    ;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
    

    【讨论】:

    • 很高兴您找到了解决方案;)
    • 感谢您的宝贵时间,JoeDF;我知道您发布的任何答案都是一个很好的答案,即使它不是我想要的答案。
    猜你喜欢
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 2016-07-24
    • 2017-10-12
    • 2023-04-03
    • 2012-07-14
    相关资源
    最近更新 更多