MerkurAlex Posted April 26, 2008 Share Posted April 26, 2008 (edited) Is there a way to make the background of a gui itself transparent not just a control or winsettrans? EDIT: nevermind solved. Edited April 26, 2008 by EagleClaw [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote] Link to comment Share on other sites More sharing options...
BrettF Posted April 26, 2008 Share Posted April 26, 2008 (edited) Is there a way to make the background of a gui itself transparent not just a control or winsettrans?EDIT: nevermind solved.Please post how for any other members that may search, so they can easily find the solution... Edited April 26, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ProgAndy Posted April 26, 2008 Share Posted April 26, 2008 (edited) So, I will post an example from me: expandcollapse popup#include <GUIConstants.au3> #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) _API_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 #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 _API_SetLayeredWindowAttributes($gui,0xABCDEF,GUICtrlRead($slidTrans)) Else _API_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 MsgBox(0, '', "Button on layered Window Clicked") Case $msg = $GUI_EVENT_CLOSE Exit MsgBox(0, '', "Close from Layered GUI") EndSelect EndSwitch WEnd #endregion ;=============================================================================== ; ; Function Name: _API_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-Strucure, 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 ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 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", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error,0,0) Case $ret[0] = 0 Return SetError(4,0,0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes Edited April 26, 2008 by ProgAndy *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...
sensalim Posted April 26, 2008 Share Posted April 26, 2008 That's a cool example. However, when I move or touch the 'main' window, it says close from layered gui. Link to comment Share on other sites More sharing options...
ProgAndy Posted April 26, 2008 Share Posted April 26, 2008 OOps Line 52 was wrong Corrected it. *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...
qwert Posted April 26, 2008 Share Posted April 26, 2008 ProgAndy, that's an excellent example. I've been working with transparency for a few weeks now and yours is the best example I've seen for bringing the various techniques together. Thank you. Link to comment Share on other sites More sharing options...
GHOSTSKIKDA Posted April 26, 2008 Share Posted April 26, 2008 thank you my friend...... [center]I LOVE ALGERIA .... ;-)[/center] Link to comment Share on other sites More sharing options...
ProgAndy Posted April 26, 2008 Share Posted April 26, 2008 Thank you man. But in reality this is only one Funkction from MSDN. I didn't understand, why a Layered Window only could be visible, if there was a Picture on it, so I searched MSDN *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...
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