darbid Posted August 12, 2008 Share Posted August 12, 2008 I have and am using this here from Lod3nTook me a while to work out that labels/controls are on the child window that is transparent and disabledI have the background picture fading in beautifully, but then it JUMPS to the text I tried to fade the child window but it is either on or off. Probably cannot fade a transparent thing.Could someone please let me know how to fade all text/buttons in as well? Link to comment Share on other sites More sharing options...
martin Posted August 12, 2008 Share Posted August 12, 2008 I have and am using this here from Lod3nTook me a while to work out that labels/controls are on the child window that is transparent and disabledI have the background picture fading in beautifully, but then it JUMPS to the text I tried to fade the child window but it is either on or off. Probably cannot fade a transparent thing.Could someone please let me know how to fade all text/buttons in as well?Can you show what you have at the moment? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ProgAndy Posted August 12, 2008 Share Posted August 12, 2008 Just use the func _WinAPI_SetLayeredWindowAttributes from http://www.autoitscript.com/forum/index.php?showtopic=74560 instead of WonSetTrans *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
darbid Posted August 12, 2008 Author Share Posted August 12, 2008 Can you show what you have at the moment?Not a problem, but it would just be almost cutting and copying the original code. when they click ok it starts. Exactly where lod3n adds text I do to. Of course I am using another png file which is much bigger and better (a brushed metal PNG) and I have a couple of textlabels.The purpose of my code is simply to ask a person if they want to install (copy) files to their computer. So I am not doing anything revolutionary.One thing i have read is that I could put the text on the background layer instead of this transparent child layer, but have not tested that yet.Just use the func _WinAPI_SetLayeredWindowAttributes from http://www.autoitscript.com/forum/index.php?showtopic=74560 instead of WonSetTrans thanks I will try tomorrow when I am in front of the other computer (grüße) Link to comment Share on other sites More sharing options...
darbid Posted August 25, 2008 Author Share Posted August 25, 2008 It has taken me a while to get back to this. here is what I have done. expandcollapse popup#include <GDIPlus.au3> #include <File.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir Global Const $PBS_SMOOTH = 0x00000001; The progress bar displays progress status in a smooth scrolling bar Global $j=1 DirCreate(@ProgramFilesDir & "\LuTTool") DirCreate(@StartMenuDir & "\LuTTool") ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @ProgramFilesDir & "\LuTTool\splash_install.png" ;$pngSrc = @ScriptDir & "\splash_install.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("LuTTool Installer", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($GUI, "", 1) ;fade in png background For $i = 0 To 255 Step 20 SetBitmap($GUI, $hImage, $i) Next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ProgramFilesDir & "\LuTTool\grey.gif", 0, 0, $width, $height) ;GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) $MyButton1 = GUICtrlCreateButton("Install", 330, 260, 85, 28, $BS_FLAT) GUICtrlSetBkColor(-1, 0xC0C0C0) GUICtrlSetFont(-1, 16, 800, 0, "Times New Roman") $MyButton2 = GUICtrlCreateButton("Quit", 460, 260, 85, 28, $BS_FLAT) GUICtrlSetBkColor(-1, 0xC0C0C0) GUICtrlSetFont(-1, 16, 800, 0, "Times New Roman") $Progress1 = GUICtrlCreateProgress(60, 310, 440, 30,$PBS_SMOOTH) GUICtrlSetColor(-1, 0x000080) GUICtrlSetBkColor(-1, 0xC0C0C0) ; set default button for Enter key activation - renders outside GUI window ;$goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $MyButton1 Call("installing") GUICtrlCreateLabel("DONE", 510, 317, 40, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman") sleep(1000) Exitloop Case $MyButton2 ExitLoop EndSwitch WEnd GUIDelete($controlGui) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() ; ==================================================================================================== ; Install function ; ==================================================================================================== Func installing() ;filecopy goes here EndFunc ;==>installing ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) ;_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 Else Return 0 EndIf EndFunc ;==>_ShellExecute The problem is that the png image comes up nice and slow. Then at the end the two button and progress jump on to the image and it flashes. Any way to make this part smoother? Link to comment Share on other sites More sharing options...
TPlanet Posted August 25, 2008 Share Posted August 25, 2008 Hello! You should find what you need in this nice code done by Prog@ndy CODE#include <GUIConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> ;############# Constants ########## Global Const $LWA_ALPHA = 0x2 Global Const $LWA_COLORKEY = 0x1 ;############# Example ############ #Region - GUI Create $gui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED) GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, "Click label to drag layered window") $layButt = GUICtrlCreateButton("Button", 10, 40, 40) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($gui, 0x010101) GUISetState() $guicontrol = GUICreate("ControlGUI", 300, 400, 100, 100) $checkTrans = GUICtrlCreateCheckbox("Transparent color 0xABCDEF (Checked) Or 0x010101", 10, 10) $checkBorder = GUICtrlCreateCheckbox("POPUP-Style", 10, 30) GUICtrlCreateLabel("Transparency for Layered GUI", 10, 50) $slidTrans = GUICtrlCreateSlider(10, 70, 200, 30) GUICtrlSetLimit($slidTrans, 255, 0) GUICtrlSetData(-1, 255) GUISetState() #EndRegion - GUI Create #Region - GUI SelectLoop While 1 $extMsg = GUIGetMsg(1) $msg = $extMsg[0] Switch $extMsg[1] Case $guicontrol Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $checkTrans Or $msg = $slidTrans ; Change Attributes of Trans-Color and Window Transparency If BitAND(GUICtrlRead($checkTrans), $GUI_CHECKED) = $GUI_CHECKED Then _WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, GUICtrlRead($slidTrans)) Else _WinAPI_SetLayeredWindowAttributes($gui, 0x010101, GUICtrlRead($slidTrans)) EndIf Case $msg = $checkBorder If BitAND(GUICtrlRead($checkBorder), $GUI_CHECKED) = $GUI_CHECKED Then GUISetStyle($WS_POPUP, -1, $gui) Else GUISetStyle($GUI_SS_DEFAULT_GUI, -1, $gui) EndIf EndSelect Case $gui Select Case $msg = $layButt Dim $transcolor, $alpha $info = _WinAPI_GetLayeredWindowAttributes($gui,$transcolor, $alpha) MsgBox(0, 'Layered GUI', "Button on layered Window Clicked" & @CRLF & "Information about this window: " & @CRLF & _ "Transparent Color: " & $transcolor & @CRLF & _ "Alpha Value: " & $alpha & @CRLF & _ "LWA_COLORKEY: " & (BitAND($info,$LWA_COLORKEY)=$LWA_COLORKEY) & @CRLF & _ "LWA_ALPHA: " & (BitAND($info,$LWA_ALPHA)=$LWA_ALPHA) ) Case $msg = $GUI_EVENT_CLOSE Exit MsgBox(0, '', "Close from Layered GUI") EndSelect EndSwitch WEnd #EndRegion - GUI SelectLoop ;############# EndExample ######### ;=============================================================================== ; ; Function Name: _WinAPI_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF( 0x00bbggrr ), else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ; Link : @@MsdnLink@@ SetLayeredWindowAttributes ; Example : Yes ;=============================================================================== ; Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False) If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else Return 1 EndSelect EndFunc ;==>_WinAPI_SetLayeredWindowAttributes ;=============================================================================== ; ; Function Name: _WinAPI_GetLayeredWindowAttributes ; Description:: Gets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Returns Transparent color ( dword as 0x00bbggrr or string "0xRRGGBB") ; $Transparency - Returns Transparancy of GUI ; $isColorRef - If True, $i_transcolor will be a COLORREF( 0x00bbggrr ), else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: Usage of LWA_ALPHA and LWA_COLORKEY (use BitAnd) ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed ; - use _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; - @extended contains _WinAPI_GetLastError ; Author(s): Prog@ndy ; ; Link : @@MsdnLink@@ GetLayeredWindowAttributes ; Example : Yes ;=============================================================================== ; Func _WinAPI_GetLayeredWindowAttributes($hwnd, ByRef $i_transcolor, ByRef $Transparency,$asColorRef = False) $i_transcolor = -1 $Transparency = -1 Local $Ret = DllCall("user32.dll", "int", "GetLayeredWindowAttributes", "hwnd", $hwnd, "long*", $i_transcolor, "byte*", $Transparency, "long*", 0) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else If Not $asColorRef Then $Ret[2] = Hex(String($Ret[2]), 6) $Ret[2] = '0x' & StringMid($Ret[2], 5, 2) & StringMid($Ret[2], 3, 2) & StringMid($Ret[2], 1, 2) EndIf $i_transcolor = $Ret[2] $Transparency = $Ret[3] Return $Ret[4] EndSelect EndFunc ;==>_WinAPI_GetLayeredWindowAttributes Have fun! Link to comment Share on other sites More sharing options...
darbid Posted August 26, 2008 Author Share Posted August 26, 2008 Hello! You should find what you need in this nice code done by Prog@ndyI appreciate the reply. That was also referred to above. And is something I do not understand, as a beginner (wanting to run before he can walk)Are you saying I should now redo everything with this new code or that I should use the API to fade in and out the text. Link to comment Share on other sites More sharing options...
TPlanet Posted August 27, 2008 Share Posted August 27, 2008 hi, You should play with it. I don't know what you exactly want as I don't have the png and gif, but you can do something like this CODE#include <GUIConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> ;############# Example ############ #Region - GUI Create $gui = GUICreate("trans", 100, 100, -1, -1, $WS_POPUP, $WS_EX_LAYERED) $layButt = GUICtrlCreateButton("Close", 10, 40, 40) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF,0) GUISetState() for $i=20 to 255 _WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, $i) Sleep(10) next While 1 $extMsg = GUIGetMsg(1) $msg = $extMsg[0] Select Case $msg = $layButt Exit EndSelect WEnd ;############# EndExample ######### ;=============================================================================== ; ; Function Name: _WinAPI_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF( 0x00bbggrr ), else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ; Link : @@MsdnLink@@ SetLayeredWindowAttributes ; Example : Yes ;=============================================================================== ; Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False) If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else Return 1 EndSelect EndFunc ;==>_WinAPI_SetLayeredWindowAttributes I tried this, but not sure it is what you want; CODE#include <GDIPlus.au3> #include <File.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" Global $launchDir = @DesktopDir Global Const $PBS_SMOOTH1 = 0x00000001; The progress bar displays progress status in a smooth scrolling bar Global $j=1 DirCreate(@ProgramFilesDir & "\LuTTool") DirCreate(@StartMenuDir & "\LuTTool") ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @ProgramFilesDir & "\LuTTool\splash_install.png" ;$pngSrc = @ScriptDir & "\splash_install.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("LuTTool Installer", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($GUI, "", 1) ;fade in png background For $i = 0 To 255 Step 20 SetBitmap($GUI, $hImage, $i) Next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic(@ProgramFilesDir & "\LuTTool\grey.gif", 0, 0, $width, $height) ;GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) $MyButton1 = GUICtrlCreateButton("Install", 330, 260, 85, 28, $BS_FLAT) GUICtrlSetBkColor(-1, 0xC0C0C0) GUICtrlSetFont(-1, 16, 800, 0, "Times New Roman") $MyButton2 = GUICtrlCreateButton("Quit", 460, 260, 85, 28, $BS_FLAT) GUICtrlSetBkColor(-1, 0xC0C0C0) GUICtrlSetFont(-1, 16, 800, 0, "Times New Roman") $Progress1 = GUICtrlCreateProgress(60, 310, 440, 30,$PBS_SMOOTH1) GUICtrlSetColor(-1, 0x000080) GUICtrlSetBkColor(-1, 0xC0C0C0) ; set default button for Enter key activation - renders outside GUI window ;$goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON) _WinAPI_SetLayeredWindowAttributes($controlGui, 0xABCDEF,0) GUISetState() for $i=20 to 255 _WinAPI_SetLayeredWindowAttributes($controlGui, 0xABCDEF, $i) Sleep(10) next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $MyButton1 Call("installing") GUICtrlCreateLabel("DONE", 510, 317, 40, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman") sleep(1000) Exitloop Case $MyButton2 ExitLoop EndSwitch WEnd GUIDelete($controlGui) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() ; ==================================================================================================== ; Install function ; ==================================================================================================== Func installing() ;filecopy goes here EndFunc ;==>installing ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) ;_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap ; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself. Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL) $aRet = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "", _ "string", $sCmd, _ "string", $sArg, _ "string", $sFolder, _ "int", $rState) If @error Then Return 0 $RetVal = $aRet[0] If $RetVal > 32 Then Return 1 Else Return 0 EndIf EndFunc ;==>_ShellExecute ;=============================================================================== ; ; Function Name: _WinAPI_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF( 0x00bbggrr ), else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ; Link : @@MsdnLink@@ SetLayeredWindowAttributes ; Example : Yes ;=============================================================================== ; Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False) If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else Return 1 EndSelect EndFunc ;==>_WinAPI_SetLayeredWindowAttributes Enjoy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now