绿色风's Blog
专注AutoIT(Au3)
  • 首页
  • 流●年
  • 笔●记
    • 学习随记
    • 源码示例
  • 脚●本
    • UDF(收集)
    • 工作室UDF
    • 工具●教程
    • 教程之GDI
  • 作●品
  • 下●载
  • 情怀ExcelTip
7月142015

窗体边缘阴影-示例

作者:绿色风   发布:2015-7-14 23:46 Tuesday   分类:   阅读:4841次   评论:0条  

窗体边缘阴影 函数

用起来很简单   

QQ图片20150626093215.png 


#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
;;a dog and pony show drop shadow example script incorporating a modified version of ProgAndy's xMsgBox UDF
;Author: rover
;Mar 8 2009
#include-once
#include <WinApi.au3>
#include <GUIConstantsEX.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

;//xMsgBox struct
Global $tMSGBOXEX_MSGHOOK

Global $hGUI, $msg, $cButton1, $cButton2, $hIcon1, $hIcon2
;Global $iStyles = Default
Global $iStyles = $WS_SYSMENU; uncomment to test resizing issues with drop shadow
$hGUI = GUICreate("Drop shadow on forms and dialogs demo", 400, 300, 100, 100, $iStyles)
_GuiSetDropShadow($hGUI) ;set drop shadow on main form
;If @error Or @extended Then xMsgBox(16 + 262144, "_GuiSetDropShadow()", "Failed to set system for drop shadow" & _
;       @CRLF & "Error: " & @error & @CRLF & "Extended: " & @extended, Default, Default, Default, 0, $hGUI)

Global $sPic = @WindowsDir & "\pchealth\helpctr\System\blurbs\watermark_300x.bmp"
If FileExists($sPic) Then
    Global $cPic = GUICtrlCreatePic(@WindowsDir & "\pchealth\helpctr\System\blurbs\watermark_300x.bmp", 50, 0, 300, 300)
    GUICtrlSetState(-1, $GUI_DISABLE)
EndIf

$cButton1 = GUICtrlCreateButton('Dialog child of parent - centred on form', 75, 50, 250, 25)
$cButton2 = GUICtrlCreateButton('Dialog not child of parent - centred on desktop', 75, 150, 250, 25)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit 0
        Case $cButton1

        Case $cButton2
    EndSwitch
WEnd

;#FUNCTION#========================================================================================
; Name...........: _GuiSetDropShadow
; Description ...: Sets the drop shadow effect on forms and dialogs for current process
; Syntax.........: _GuiSetDropShadow($hwnd, $fDisrespectUser = True)
; Parameters ....: $hWnd                   - Handle to parent form or child dialog (GuiCreate(), MsgBox(), FileOpenDialog(), etc.)
;                         $fDisrespectUser    - True: (Default) - set system option for drop shadow if disabled by user
;                                                      - False:             - do not set system option for drop shadow if disabled by user
; Return values .: Success      - 1
;                         Failure         - 0       - @error set and @extended set to point of failure
; Author(s) ........: rover, (lod3n, Rasim for Get/SetClassLong, Kip - RegisterclassEx() for drop shadow idea, ProgAndy - xMsgBox hook)
; Remarks .......: Note: drop shadow is lost if parent form clicked on (If MsgBox created with parent handle)
;                                 hiding, then restoring MsgBox to foreground or moving MsgBox off of form restores drop shadow.
;                                 use 262144 or 4096 flags with MsgBox if using with hParent handle to prevent loss of drop shadow if parent clicked on.
;                                 this behaviour is apparently by design.
;+
;                  Minimum Operating Systems: Windows XP
; Related .......:
; Link ..........; @@MsdnLink@@ SetClassLong Function
; Example .......; Yes
; ===================================================================================================
Func _GuiSetDropShadow($hwnd, $fDisrespectUser = True)
    If Not IsHWnd($hwnd) Then Return SetError(1, 1, 0)

    ;check if hWnd is from current process
    Local $aResult = DllCall("User32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hwnd, "int*", 0)
    If @error Or $aResult[2] <> @AutoItPID Then Return SetError(@error, 2, 0)

    If Not IsDeclared("SPI_GETDROPSHADOW") Then Local Const $SPI_GETDROPSHADOW = 0x1024
    If Not IsDeclared("SPI_SETDROPSHADOW") Then Local Const $SPI_SETDROPSHADOW = 0x1025
    If Not IsDeclared("CS_DROPSHADOW") Then Local Const $CS_DROPSHADOW = 0x00020000
    If Not IsDeclared("GCL_STYLE") Then Local Const $GCL_STYLE = -26

    $aResult = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETDROPSHADOW, "int", 0, "int*", 0, "int", 0)
    Local $iErr = @error
    If $iErr Or Not IsArray($aResult) Then Return SetError($iErr, 3, 0)

    ;if 'Show shadows under menus' option not set, try activating it.
    If Not $aResult[3] And $fDisrespectUser Then
    ;turn on drop shadows
        $aResult = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETDROPSHADOW, "int", 0, "int", True, "int", 0)
        $iErr = @error
        If $iErr Or Not IsArray($aResult) Or $aResult[0] <> 1 Then Return SetError($iErr, 4, 0)
    EndIf

    ;get styles from WndClassEx struct
    $aResult = DllCall("user32.dll", "dword", "GetClassLong", "hwnd", $hwnd, "int", $GCL_STYLE)
    $iErr = @error
    If $iErr Or Not IsArray($aResult) Or Not $aResult[0] Then Return SetError($iErr, 5, 0)
    Local $OldStyle = $aResult[0]

    ;add drop shadow style to styles
    Local $Style = BitOR($OldStyle, $CS_DROPSHADOW)

    If StringRight(@OSArch, 2) == "64" Then
        ;if 64 bit windows (NOT TESTED)
        ;see MSDN SetClassLong remarks
        ;$aResult = DllCall("user32.dll", "ulong_ptr", "SetClassLongPtr", "hwnd", $hWnd, "int", $GCL_STYLE, "long_ptr", $Style)
        ;$iErr = @error
        ;If $iErr Or Not IsArray($aResult) Or Not $aResult[0] Then Return SetError($iErr, 6, 0)
    Else
        $aResult = DllCall("user32.dll", "dword", "SetClassLong", "hwnd", $hwnd, "int", $GCL_STYLE, "long", $Style)
        $iErr = @error
        If $iErr Or Not IsArray($aResult) Or Not $aResult[0] Then Return SetError($iErr, 7, 0)
        If $aResult[0] = $OldStyle Then Return SetError($iErr, 0, 1)
        Return SetError($iErr, 8, 0)
    EndIf
EndFunc  ;==>_GuiSetDropShadow```

 





本文固定链接: http://www.jianyiit.com/post-114.html

blogger
该日志由 绿色风 于2015-7-14 23:46 Tuesday发表在 分类下。
版权所有:《绿色风's Blog》 → 《窗体边缘阴影-示例》;
除特别标注,本博客很多文章均为原创. 互联分享,尊重版权,转载请以链接形式标明本文地址;
本文标签:

扫描二维码,在手机上阅读
上一篇::AU3能清除IE7以上临时文件、Cookie、历史记录、表单数据等内容
下一篇:新编winapi大全

热门文章

相关文章

  • Au3[规则验证码]自动识别,并输出程序
  • AU3键盘HOOK
  • 跟随鼠标的图型
  • GDI+示例1
  • Au3中文内码转换UDF,方便调用
取消回复

发表评论

亲,头像对么?

29 + 89 =

提交中,请稍候……


木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!


    站点统计
    • 运行时间: 20254 天
    • 日志总数: 365 篇
    • 评论数量: 7237 条
    • 微语数量: 6 条
    • 附件总量: 388 件
  • 逝出的青春

  • 打赏"绿色风"



      扫码关注本站公众号 可搜本站内容

  • Autoit V3 脚本交流群

      常驻群1:905774875
      常驻群2:40672266


  • 链接

    • AU3中文论坛
    • Excel资料库
    • 完美者博客
    • 顺网小哥'S Blog
    • 猛牛哥的博客
    • 网吧系统下载
  • 分类

    • 流●年(66)
    • 笔●记(0)
    • 脚●本(0)
    • 作品(21)
    • 学习随记(51)
    • 源码示例(68)
    • UDF(收集)(26)
    • 工作室UDF(30)
    • 工具●教程(62)
    • 教程之GDI(24)
Copyright © 2013 绿色风's Blog. Powered by emlog. Theme by 射雕天龙. 鄂ICP备2021011689号-1 鄂公网安备42102302000078号 sitemap