NiVZ Posted August 19, 2008 Share Posted August 19, 2008 Hello, I'm making a GUI with a background picture and can make the picture show through the LABEL controls using GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT). I want to do the same for my GUICtrlCreateGroup controls but the text for the title of the group is showing with a solid background color. Any suggestions? Thanks, NiVZ Link to comment Share on other sites More sharing options...
ulti Posted August 21, 2008 Share Posted August 21, 2008 i am allso trying to achive this but u cannot use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) i know that dosent work Link to comment Share on other sites More sharing options...
rasim Posted August 21, 2008 Share Posted August 21, 2008 NiVZExample 1expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global Const $TRANSPARENT = 1 GUICreate("My GUI", 300, 200) $pic = GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 300, 200) GUICtrlSetState(-1, $GUI_DISABLE) $group = GUICtrlCreateGroup("Group1", 10, 10, 280, 100) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ") GUICtrlCreateGroup("", -99, -99, 1, 1) GUIRegisterMsg($WM_CTLCOLORSTATIC, "WM_CTLCOLORSTATIC") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_CTLCOLORSTATIC($hWnd, $Msg, $wParam, $lParam) DllCall("gdi32.dll", "int", "SetBkMode", "hwnd", $wParam, "int", $TRANSPARENT) ;DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $wParam, "int", 0xFF0000) If $lParam = GUICtrlGetHandle($group) Then Return _WinAPI_GetStockObject($NULL_BRUSH) EndFuncoÝ÷ ØLZ^ooÛjëh×6#include <GuiConstantsEx.au3> #include <StaticConstants.au3> $hGUI = GUICreate("Test", 300, 200) GUICtrlCreatePic(@WindowsDir & "\web\Wallpaper\Windows XP.jpg", 0, 0, 300, 200) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("", 10, 10, 10, 2, $SS_SUNKEN) GUICtrlCreateLabel("Group 1", 22, 4, 40, 16) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateLabel("", 64, 10, 225, 2, $SS_SUNKEN) GUICtrlCreateLabel("", 288, 10, 2, 100, $SS_SUNKEN) GUICtrlCreateLabel("", 10, 10, 2, 100, $SS_SUNKEN) GUICtrlCreateLabel("", 10, 110, 280, 2, $SS_SUNKEN) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
NiVZ Posted August 21, 2008 Author Share Posted August 21, 2008 (edited) Thanks Rasim. I managed to get something like Example 1 by just making the group and then putting a transparent label in the top corner. Saves making the DLL call. Example 2 is what I really want it to look like. Just a shame you have to draw the 5 lines of the rectangle yourself Hopefully the functionality will be added to AutoIt to let you use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) with Group controls as that would be a lot easier. Thanks for your examples though - they should make a decent work-around. Think I'll write a little function to create the custom Groups so I can just pass it a string and the co-ordinates and it will draw it for me - just need to figure out the string length in pixels so I can start at the end of the group title. Is there any way to do this with buttons as well? I'd like the background to show through the buttons, but don't want to have to create images for the text on the button. NiVZ Edited August 21, 2008 by NiVZ Link to comment Share on other sites More sharing options...
rasim Posted August 22, 2008 Share Posted August 22, 2008 NiVZTrick example:expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Global Const $ODT_BUTTON = 4 Global Const $DFC_BUTTON = 4 Global Const $DFCS_BUTTONPUSH = 0x0010 Global Const $ODS_SELECTED = 0x0001 Global Const $TRANSPARENT = 1 Global $Draw = False Global $aCurPos $hGUI = GUICreate("My GUI", 300, 200) $pic = GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 300, 200) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateLabel("Test", 100, 65, 100, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState() FrameRect1(GUICtrlGetHandle($button), 0xFFFFFF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $button MsgBox(0, "Info", "Button pressed", 0, $hGUI) EndSwitch $aCurPos = GUIGetCursorInfo() If IsArray($aCurPos) Then If ($aCurPos[4] = $button) And ($Draw = False) Then $Draw = True GUICtrlSetColor($button, 0xFF0000) GUICtrlSetFont($button, 10, 800) FrameRect1(GUICtrlGetHandle($button), 0x0000FF) ElseIf ($aCurPos[4] <> $button) And ($Draw = True) Then $Draw = False GUICtrlSetColor($button, 0) GUICtrlSetFont($button, Default, Default) FrameRect1(GUICtrlGetHandle($button), 0xFFFFFF) EndIf EndIf WEnd Func FrameRect1($hWnd, $sColor) ;$hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush Local $hDC = _WinAPI_GetDC($hWnd) Local $tRect = _WinAPI_GetClientRect($hWnd) Local $hBrush = _WinAPI_CreateSolidBrush($sColor) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($tRect), "hwnd", $hBrush) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteObject($hBrush) EndFunc 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