7月142015
窗体边缘阴影-示例
窗体边缘阴影 函数
用起来很简单
#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```
扫描二维码,在手机上阅读
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!