/*
https://github.com/jNizM/AHK_Scripts/tree/master/src/gui
禁用/启用窗口关闭按钮
启用/禁用移动窗口
开启窗口边框阴影效果
*/
Gui,test:Destroy
Gui,test:+AlwaysOnTop +HWNDGuiTest
SetWindowsFrameShadow(GuiTest)
ToggleGuiCloseButton(GuiTest,OnOff:=False)
ToggleGuiMove(GuiTest,EnableMove:=False)
Gui,test:Add,Edit,w200 HWNDEditBox,
EM_SETCUEBANNER(EditBox, "Edit输入框")
Gui,test:Add,ComboBox,w200 HWNDCBoxTest,1|2|3
CB_SETCUEBANNER(CBoxTest, "ComboBox选择框")
Gui,test:Add,Button,w200 gbuttonTest vIsClose,% "启用/禁用关闭按钮"
Gui,test:Add,Button,w200 gbuttonTest vIsMove,% "启用/禁用移动窗口"
Gui,test:Show,w250 h200
Return
testGuiClose:
ExitApp
Return
buttonTest:
Switch A_GuiControl
{
Case "IsClose":
OnOff:=!OnOff
ToggleGuiCloseButton(GuiTest,OnOff)
Case "IsMove":
EnableMove:=!EnableMove
ToggleGuiMove(GuiTest,EnableMove)
}
Return
;;无边框窗口加阴影效果
SetWindowsFrameShadow(handle){
DllCall("dwmapi.dll\DwmIsCompositionEnabled", "int*", DwmEnabled)
if !(DwmEnabled)
DllCall("user32.dll\SetClassLongPtr", "ptr", handle, "int", -26, "ptr", DllCall("user32.dll\GetClassLongPtr", "ptr", handle, "int", -26) | 0x20000)
else {
VarSetCapacity(MARGINS, 16, 0) && NumPut(1, NumPut(1, NumPut(1, NumPut(1, MARGINS, "int"), "int"), "int"), "int")
DllCall("dwmapi.dll\DwmSetWindowAttribute", "ptr", handle, "uint", 2, "ptr*", 2, "uint", 4)
DllCall("dwmapi.dll\DwmExtendFrameIntoClientArea", "ptr", handle, "ptr", &MARGINS)
}
}
;;启用/禁用移动窗口
ToggleGuiMove(handle,Enable:=True){
hMenu := DllCall("user32\GetSystemMenu", "ptr", handle, "int", Enable, "ptr")
DllCall("user32\RemoveMenu", "ptr", hMenu, "uint", 0xf010, "uint", 0x0)
return DllCall("user32\DrawMenuBar", "ptr", handle)
}
;;禁用/启用窗口关闭按钮
ToggleGuiCloseButton(handle,Enable:=True){
hMenu := DllCall("user32\GetSystemMenu", "ptr", handle, "int", Enable, "ptr")
DllCall("user32\EnableMenuItem", "ptr", hMenu, "uint", 0xf060, "uint", 0x3)
return DllCall("user32\DrawMenuBar", "ptr", handle)
}
;;设置Edit控件默认提示文本
EM_SETCUEBANNER(handle, string, hideonfocus := true){
static EM_SETCUEBANNER := 0x1501
return DllCall("user32\SendMessage", "ptr", handle, "uint", EM_SETCUEBANNER, "int", hideonfocus, "str", string, "int")
}
;;设置Combobox控件默认提示文本
CB_SETCUEBANNER(handle, string){
static CB_SETCUEBANNER := 0x1703
return DllCall("user32\SendMessage", "ptr", handle, "uint", CB_SETCUEBANNER, "int", 0, "str", string, "int")
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
?
认真学习中,谢谢分享