jazzyjeff Posted October 31, 2012 Share Posted October 31, 2012 (edited) Hello, I know there are many articles on creating labels that are transparent, because I have spent a few hours reading them. However, I am not able to figure this out still and I am hoping for a bit of help/guidance. I want the $lblMain variable, which is a label to have a transparent background. I am not able to get this though. Here is my code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <WinAPIEx.au3> #Region ### START Koda GUI section ### Form= $mainForm = GUICreate("System Testing", 524, 212, -1, -1, $WS_POPUP);,BitAND($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE)) $btnStaff = GUICtrlCreateButton("Staff", 8, 40, 161, 161) GUICtrlSetFont(-1, 24, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x00FFFF) $btnExit = GUICtrlCreateButton("Exit", 354, 40, 161, 161) GUICtrlSetFont(-1, 24, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x00FFFF) $btnStudents = GUICtrlCreateButton("Students", 181, 40, 161, 161) GUICtrlSetFont(-1, 24, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x00FFFF) $lblMain = GUICtrlCreateLabel("Please choose the type of user that this test is designed for.", 8, 10, 440, 24,"",BitOR($GUI_WS_EX_PARENTDRAG,$WS_EX_TRANSPARENT)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 16, 400, 0, "Arial") GUISetState(@SW_SHOW,$mainForm) #EndRegion ### END Koda GUI section ### GUISetControlsVisible($mainForm) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnExit Exit EndSwitch WEnd Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255) global $pHwnd, $nHwnd, $aPos, $a $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle If $hWnd = 0 then Return SetError(1,1,0) $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle If $pHwnd[0] = 0 then Return SetError(1,2,0) $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control If @error then Return SetError(1,3,0) $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control If $nHwnd = 0 then Return SetError(1,4,0) $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui If $a[0] = 0 then Return SetError(1,5,0) If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui GUISetState(@SW_Show,$nHwnd);show the new child gui WinSetTrans($nHwnd,"",$iTrans);set the transparency If @error then Return SetError(1,7,0) GUISwitch($pHwnd[0]);switch back to the parent Gui Return $nHwnd;Return the handle for the new Child gui EndFunc Func GUISetControlsVisible($hWnd) Local $aM_Mask, $aCtrlPos, $aMask $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1)) For $i = 3 To $aLastID[0] $aCtrlPos = ControlGetPos($hWnd, '', $i) If Not IsArray($aCtrlPos) Then ContinueLoop $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _ "long", $aCtrlPos[0], _ "long", $aCtrlPos[1], _ "long", $aCtrlPos[0] + $aCtrlPos[2], _ "long", $aCtrlPos[1] + $aCtrlPos[3]) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1) EndFunc Func _Student() #Region ### START Koda GUI section ### Form= $formStudents = GUICreate("Student System test", 646, 366, 773, 148) $btnStart2 = GUICtrlCreateButton("Start", 14, 312, 139, 41) $btnReport2 = GUICtrlCreateButton("Report", 168, 313, 139, 41) $btnConfigure2 = GUICtrlCreateButton("Configure", 325, 314, 139, 41) $btnClose2 = GUICtrlCreateButton("Close", 487, 314, 139, 41) $listTasks2 = GUICtrlCreateList("", 14, 16, 617, 240) $Progress2 = GUICtrlCreateProgress(14, 264, 614, 17) $lblPercent2 = GUICtrlCreateLabel("%", 14, 288, 12, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 2 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func _Staff() #Region ### START Koda GUI section ### Form= $formStaff = GUICreate("Staff System test", 646, 366, 773, 148) $btnStart1 = GUICtrlCreateButton("Start", 14, 312, 139, 41) $btnReport1 = GUICtrlCreateButton("Report", 168, 313, 139, 41) $btnConfigure1 = GUICtrlCreateButton("Configure", 325, 314, 139, 41) $btnClose1 = GUICtrlCreateButton("Close", 487, 314, 139, 41) $listTasks1 = GUICtrlCreateList("", 14, 16, 617, 240) $Progress1 = GUICtrlCreateProgress(14, 264, 614, 17) $lblPercent1 = GUICtrlCreateLabel("%", 14, 288, 12, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 3 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Edited October 31, 2012 by jazzyjeff Link to comment Share on other sites More sharing options...
JScript Posted October 31, 2012 Share Posted October 31, 2012 See if that is what you want: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <WinAPIEx.au3> #region ### START Koda GUI section ### Form= $mainForm = GUICreate("System Testing", 524, 212, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetBkColor(0xABABAB) Switch @OSVersion Case "WIN_2000", "WIN_XP", "WIN_XPe", "WIN_2003" _WinAPI_SetLayeredWindowAttributes($mainForm, 0xABABAB, 255, $LWA_COLORKEY) Case Else _WinAPI_SetLayeredWindowAttributes($mainForm, 0xABABAB, 255, BitOR($LWA_COLORKEY, $LWA_ALPHA)) EndSwitch $btnStaff = GUICtrlCreateButton("Staff", 8, 40, 161, 161) GUICtrlSetFont(-1, 24, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x00FFFF) $btnExit = GUICtrlCreateButton("Exit", 354, 40, 161, 161) GUICtrlSetFont(-1, 24, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x00FFFF) $btnStudents = GUICtrlCreateButton("Students", 181, 40, 161, 161) GUICtrlSetFont(-1, 24, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x00FFFF) $lblMain = GUICtrlCreateLabel("Please choose the type of user that this test is designed for.", 8, 10, 480, 24, BitOR($SS_SIMPLE, $SS_CENTER)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 14, 400, 0, "Arial") GUISetState(@SW_SHOW, $mainForm) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnExit Exit EndSwitch WEnd JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 31, 2012 Share Posted October 31, 2012 (edited) # added onHover and onclick Colors to JScript code # added FOR loop for assigning colors to the buttonsexpandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <WinAPIEx.au3> #region ### START Koda GUI section ### Form= $mainForm = GUICreate("System Testing", 524, 212, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetBkColor(0xABABAB) _WinAPI_SetLayeredWindowAttributes($mainForm, 0xABABAB, 255, BitOR($LWA_COLORKEY, $LWA_ALPHA)) $btnStaff = GUICtrlCreateButton("Staff", 8, 40, 161, 161) $btnExit = GUICtrlCreateButton("Exit", 354, 40, 161, 161) $btnStudents = GUICtrlCreateButton("Students", 181, 40, 161, 161) For $n = $btnStaff To $btnStudents GUICtrlSetFont($n, 24, 800, 0, "Arial") GUICtrlSetColor($n, 0xFFFFFF) GUICtrlSetBkColor($n, 0x00FFFF) Next $lblMain = GUICtrlCreateLabel("Please choose the type of user that this test is designed for.", 8, 10, 480, 24, BitOR($SS_SIMPLE, $SS_CENTER)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 14, 400, 0, "Arial") GUISetState(@SW_SHOW, $mainForm) #endregion ### END Koda GUI section ### Local $ColorSet = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $btnExit Exit EndSwitch $nCursor = GUIGetCursorInfo($mainForm) Switch $nCursor[4] Case $btnStaff To $btnStudents Switch $nCursor[2] Case 1 GUICtrlSetColor($nCursor[4], 0x000000) $ColorSet=False Case Else If Not $ColorSet Then GUICtrlSetColor($nCursor[4], 0xFF00FF) $ColorSet = True EndIf EndSwitch Case Else If $ColorSet Then For $n = $btnStaff To $btnStudents If $n = $nCursor[4] Then ContinueLoop GUICtrlSetColor($n, 0xFFFFFF) Next $ColorSet = False EndIf EndSwitch WEnd Edited October 31, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
jazzyjeff Posted October 31, 2012 Author Share Posted October 31, 2012 SOrry for the delay in getting back to you both. Both options work great. I appreciate your time and help. 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