Truong Posted November 26, 2010 Share Posted November 26, 2010 Hi guys, I'm wondering how can we set the background of the slider transparent? Because I put the slider on an image, so the background of slider make the GUI look really bad! "GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)" does not work for slider! I would thank for anyone who either read or reply ^^! http://www.facebook.com/xx3004?sk=info Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 26, 2010 Share Posted November 26, 2010 (edited) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hButton), "wstr", 0, "wstr", 0) Edited November 26, 2010 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Truong Posted November 26, 2010 Author Share Posted November 26, 2010 (edited) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hButton), "wstr", 0, "wstr", 0) Hi AmiraAlkex, I've try your code, it does not work, here is the whole code: $opa = GUICtrlCreateSlider(312, 120, 102, 45, $TBS_NOTICKS, $WS_EX_TRANSPARENT); GUICtrlSetLimit(-1, 150, 0); GUICtrlSetData(-1, 150); $iLastSlider=150; DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($opa), "wstr", 0, "wstr", 0) Thanks for your help, do you come up with any other idea Edited November 26, 2010 by Truong http://www.facebook.com/xx3004?sk=info Link to comment Share on other sites More sharing options...
JoHanatCent Posted November 26, 2010 Share Posted November 26, 2010 How about creating a 2nd Gui and put the slider in there? You can then set that gui with: WinSetTrans($Gui2, "", 150) The slider wil then fade with it. Link to comment Share on other sites More sharing options...
picea892 Posted November 26, 2010 Share Posted November 26, 2010 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> $bkwin=GUICreate("bkcontrols", 250, 200, -1, -1) GUISetBkColor(0x000000) GUISetState() $hGUI = GUICreate("controls", 250, 200, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $bkwin) GUISetBkColor(0xABCDEF) $slider1 = GUICtrlCreateSlider(10, 10, 200, 20) GUICtrlSetBkColor(-1,0xABCDEF) GUICtrlSetLimit(-1, 200, 0) ; change min/max value $button = GUICtrlCreateButton("Value?", 75, 70, 70, 20) GUISetState() GUICtrlSetData($slider1, 45) ; set cursor _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Truong Posted November 26, 2010 Author Share Posted November 26, 2010 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> $bkwin=GUICreate("bkcontrols", 250, 200, -1, -1) GUISetBkColor(0x000000) GUISetState() $hGUI = GUICreate("controls", 250, 200, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $bkwin) GUISetBkColor(0xABCDEF) $slider1 = GUICtrlCreateSlider(10, 10, 200, 20) GUICtrlSetBkColor(-1,0xABCDEF) GUICtrlSetLimit(-1, 200, 0) ; change min/max value $button = GUICtrlCreateButton("Value?", 75, 70, 70, 20) GUISetState() GUICtrlSetData($slider1, 45) ; set cursor _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Hi, thanks for your help. The problem here is I've already used 2 layers to change the windows skin already : I have attached the file so that it will be easier for you guys to help me make the slider background transparent. Look at this picture, the slider make my GUI look terrible! Test.au3 http://www.facebook.com/xx3004?sk=info Link to comment Share on other sites More sharing options...
picea892 Posted November 26, 2010 Share Posted November 26, 2010 Hi. Yeah it can be tough merging different scripts together. Here is the solution...I hope. Your attached picture is way to small though. expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <SliderConstants.au3> Global Const $AC_SRC_ALPHA = 1 _GDIPlus_Startup() $aOT=true $pngSrc = @ScriptDir & "\bg.jpg" ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") $GUI = _GUICreate_Alpha("Primary", $pngSrc) ; create primary gui $myGuiHandle = WinGetHandle("Primary") GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) GUICtrlSetState(-1, $GUI_DISABLE); $proDef = GUICtrlCreateInput("/d", 10, 40, 49, 21); $query = GUICtrlCreateInput("", 66, 40, 289, 21); $submit = GUICtrlCreateButton("Go !", 364, 38, 43, 25, $BS_DEFPUSHBUTTON); $ESF = GUICtrlCreateCheckbox("", 10, 70, 13, 13); GUICtrlSetState(-1, $GUI_CHECKED); $l1 = GUICtrlCreateLabel("Enable Smart Filter (Automatically defines application to lauch)", 27, 70, 378, 17); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT); ;GUICtrlSetColor(-1, 0x000000); ;GUICtrlSetBkColor(-1, 0xFFFFFF); $headerTitle = GUICtrlCreateLabel("Multiple Tasks Laucher", 12, 10, 180, 23); GUICtrlSetFont(-1, 12, 800, 0, "Arial"); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT); $config = GUICtrlCreateButton("Configure", 48, 90, 75, 25); $extend = GUICtrlCreateButton("Extend", 136, 90, 75, 25); $about = GUICtrlCreateButton("Help / About", 224, 90, 75, 25); $exit = GUICtrlCreateButton("Exit", 308, 90, 75, 25); $pBar = GUICtrlCreateProgress(5, 142, 418, 20); $stt = GUICtrlCreateLabel("Welcome to Multi Tasks Launcher", 14, 122, 315, 17); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT); $opa = GUICtrlCreateSlider(312, 120, 102, 45, $TBS_NOTICKS, $WS_EX_TRANSPARENT); GUICtrlSetBkColor(-1,0xABCDEF) GUICtrlSetLimit(-1, 150, 0); GUICtrlSetData(-1, 150); $iLastSlider=150; $alwaysTop = GUICtrlCreateCheckbox("", 312, 13, 13, 13); If $aOT=True Then GUICtrlSetState(-1, $GUI_CHECKED); EndIf $lb2 = GUICtrlCreateLabel("Always on top", 336, 13, 70, 17); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT); _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) GUISetState() GUISetState() $i = 0 While 1 $i = $i + 1 If $i = 255 Then $i = 0 $msg = GUIGetMsg() $advMsg = GUIGetMsg(1) Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd _GDIPlus_Shutdown() Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $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", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha 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_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Link to comment Share on other sites More sharing options...
Truong Posted November 26, 2010 Author Share Posted November 26, 2010 Hi.Yeah it can be tough merging different scripts together. Here is the solution...I hope. Your attached picture is way to small though....Thanks for your help Picea, combination of different scripts make something impossible (i think), you script make the background black, not transparent . I think I should try the other way instead of slider, updown control for instance.I'm still expecting for help ,and thank you again.PS: About the attached pictures, I thought you would download it for easier test http://www.facebook.com/xx3004?sk=info Link to comment Share on other sites More sharing options...
Yashied Posted November 27, 2010 Share Posted November 27, 2010 (edited) expandcollapse popup#Include <Constants.au3> #Include <GUIConstantsEx.au3> #Include <SliderConstants.au3> #Include <StaticConstants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam' Global Const $STM_GETIMAGE = 0x0173 Global $hTemp = 0 GUICreate('MyGUI', 413, 161) GUICtrlCreatePic(@ScriptDir & '\bg.jpg', 0, 0, 413, 161) GUICtrlSetState(-1, $GUI_DISABLE) $hPic = GUICtrlGetHandle(-1) GUICtrlCreateSlider(200, 100, 200, 23, $TBS_NOTICKS) $hSlider = GUICtrlGetHandle(-1) GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom') Local $Code = DllStructGetData($tNMCD, 'Code') Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage') Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec') Local $hDC = DllStructGetData($tNMCD, 'hDC') Local $hMemDC, $hBitmap, $hPrev Local $aPos Switch $hWndFrom Case $hSlider Switch $Code Case $NM_CUSTOMDRAW Switch $DrawStage Case $CDDS_PREPAINT, $CDDS_POSTPAINT $aPos = ControlGetPos($hSlider, '', '') Switch $DrawStage Case $CDDS_PREPAINT $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0], $aPos[1], $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT) Case $CDDS_POSTPAINT $hMemDC = _WinAPI_CreateCompatibleDC($hDC) If Not $hTemp Then $hTemp = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3]) $hPrev = _WinAPI_SelectObject($hMemDC, $hTemp) _WinAPI_BitBlt($hMemDC, 0, 0, $aPos[2], $aPos[3], $hDC, 0, 0, $MERGECOPY) Else $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hTemp) _WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, 0, 0, $SRCCOPY) EndIf _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_DODEFAULT EndSwitch Case $CDDS_ITEMPREPAINT If $hTemp Then _WinAPI_DeleteObject($hTemp) $hTemp = 0 EndIf Switch $ItemSpec Case $TBCD_TICS Return $CDRF_SKIPDEFAULT Case $TBCD_THUMB, $TBCD_CHANNEL Return $CDRF_DODEFAULT EndSwitch EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edited November 27, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Truong Posted November 27, 2010 Author Share Posted November 27, 2010 Thank you Yashied it works perfectly! http://www.facebook.com/xx3004?sk=info Link to comment Share on other sites More sharing options...
Yashied Posted November 27, 2010 Share Posted November 27, 2010 Your welcome. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
rover Posted November 28, 2010 Share Posted November 28, 2010 Greetings Yashied you can eliminate the focus rectangle on the slider with this line after CDS_PREPAINT DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) this never worked for buttons so I disregarded it until I looked at the great example you posted above I never tried it for sliders before Case $CDDS_PREPAINT $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_BitBlt($hDC, 0, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0], $aPos[1], $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT) I see fascists... Link to comment Share on other sites More sharing options...
Yashied Posted November 28, 2010 Share Posted November 28, 2010 Greetings to you, Rover! Nice addition if to someone does not like a focus rectangle. Thanks. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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