Gui加边缘阴影.ahk

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=29117
Gui, +HwndHGui -Caption
FrameShadow(HGui)
Gui, Add, Button, x10 y130 w100 h30, Minimize
Gui, Add, Button, x365 y130 w100 h30, Exit
Gui, Add, GroupBox, x10 y10 w455 h110, GroupBox
Gui, Add, Edit, x20 y30 w435 h80 +Multi, Edit
Gui, Show, Center w475 h166, Frame Shadow Test
Return

ButtonExit:
GuiClose:
ExitApp

ButtonMinimize:
WinMinimize, A
return

FrameShadow(HGui) {
  DllCall("dwmapi\DwmIsCompositionEnabled","IntP",_ISENABLED) ; 获取DWM管理器是否已启用
  if !_ISENABLED ; 如果未启用DWM,则生成基本阴影
    DllCall("SetClassLong","UInt",HGui,"Int",-26,"Int",DllCall("GetClassLong","UInt",HGui,"Int",-26)|0x20000)
  else {
    VarSetCapacity(_,16)
    , NumPut(1,&_,0,"UInt"), NumPut(1,&_,4,"UInt"), NumPut(1,&_,8,"UInt"), NumPut(1,&_,12,"UInt")
    , DllCall("dwmapi\DwmSetWindowAttribute", "Ptr", HGui, "UInt", 2, "Int*", 2, "UInt", 4)
    , DllCall("dwmapi\DwmExtendFrameIntoClientArea", "Ptr", HGui, "Ptr", &_)
  }
}

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) {
  static init := OnMessage(0x0201, "WM_LBUTTONDOWN")
  PostMessage, 0xA1, 2,,, A
}

 

Gui加三种阴影.ahk

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=29117
; 原贴内有更多示例

#NoEnv
CS_DROPSHADOW := 0x00020000
ClassStyle := GetGuiClassStyle()

Gui,  New1:New, +hwndHGUI
SetGuiClassStyle(HGUI, ClassStyle | CS_DROPSHADOW)
Gui,  New1:Show, x100 y100 w250 h200, Test 1

SetGuiClassStyle(HGUI, ClassStyle)
Gui, New
Gui, Show, x400 y100 w250 h200, Test 2

Gui, New, +hwndHGUI
SetGuiClassStyle(HGUI, ClassStyle | CS_DROPSHADOW)
Gui,  New2:Show, x700 y100 w250 h200, Test 3
SetGuiClassStyle(HGUI, ClassStyle)

Return

GuiClose:
GuiEscape:
  ExitApp

GetGuiClassStyle() {
  Gui, GetGuiClassStyleGUI:Add, Text
  Module := DllCall("GetModuleHandle", "Ptr", 0, "UPtr")
  VarSetCapacity(WNDCLASS, A_PtrSize * 10, 0)
  ClassStyle := DllCall("GetClassInfo", "Ptr", Module, "Str", "AutoHotkeyGUI", "Ptr", &WNDCLASS, "UInt")
            ? NumGet(WNDCLASS, "Int")
            : ""
  Gui, GetGuiClassStyleGUI:Destroy
  Return ClassStyle
}

SetGuiClassStyle(HGUI, Style) {
  Return DllCall("SetClassLong" . (A_PtrSize = 8 ? "Ptr" : ""), "Ptr", HGUI, "Int", -26, "Ptr", Style, "UInt")
}

 

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。