Jump to content
Sign in to follow this  
demandnothing

Transparent Control Backgrounds

Recommended Posts

demandnothing

i did a script to download an image off the internet and set it as the interface background.. works perfectly.. here's my problem.

The controls on the interface have a regular color to them, buttonface of course. i tried using $GUI_BKCOLOR_TRANSPARENT, but it didnt change anything. can anybody help me make the interface controls transparent? checkboxes, listboxes, sliders, and what not?

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
demandnothing

Posted Image

it works, but not for what im lookin for.. instead of changing what i want to be transparent it changes it to blue, and it changes the font to be white. is there a specific way im not using this? i tried it with only applying it to the GUI, but it was still the same as without it, just couldn't move the window, it didn't have a title, or exit button lol

i want the buttonface background to go away from the controls while still being able to visibly see them.. and the sad part is, i didnt put that on the input boxes or buttons, but they both still turned out like that.. even without the set up for $Form1

Edited by demandnothing

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
funkey

With Beta 3.3.1.0 something was added:

- Added #604: $GUI_BKCOLOR_TRANSPARENT can be used with label, group, radio, checkbox controls.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
picea892

Didn't know it was in the Beta, that's good news. A method I have successfully used is below. I got it off the forum somewhere.

Picea

#include <GUIConstants.au3>
#Include <WinAPI.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$hWndMain      = GUICreate("My CheckBox Button with Transparency", 300, 200, -1, -1,$WS_OVERLAPPEDWINDOW)
GUISetBkColor(0x00ff00)

$btnCheckBox3=GUICtrlCreateLabel("testing",0,0,100,20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")
$btnCheckBox   = GUICtrlCreateCheckbox('Checkbox', 100, 30, 100, 20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")
$btnCheckBox2   = GUICtrlCreateRadio('radio', 100, 150, 80, 20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")

; will we see the pic instead of green ... ? I don't think so ...
GUISetState()

While True

    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch

WEnd

Share this post


Link to post
Share on other sites
demandnothing

You cant set the font color with GUICtrlSetColor(-1, color) - example: 0xFFFFFF

This is because of $WS_POPUP (replace it with: -1)

Looks to me like you need a png buttons instead of normal ones. Take a look at my Launcher - it uses png images as buttons (and labels just to get the information about position): Playlet's Launcher

i checked out that thread, and it seems that you are mistaken on my request here. I'm looking to make the backgrounds transparent. See through, so that all you see of the buttons are the Text/Captions. Also wanting to do this for checkboxes, sliders, and listboxes.

With Beta 3.3.1.0 something was added:

- Added #604: $GUI_BKCOLOR_TRANSPARENT can be used with label, group, radio, checkbox controls.

if you'd read the first post i stated that i used that already and it did not work. GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) doesn't change the background of sliders, checkboxes, listboxes, or buttons to be transparent. the only thing i can find that it works for is Labels.

Didn't know it was in the Beta, that's good news. A method I have successfully used is below. I got it off the forum somewhere.

Picea

#include <GUIConstants.au3>
#Include <WinAPI.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$hWndMain      = GUICreate("My CheckBox Button with Transparency", 300, 200, -1, -1,$WS_OVERLAPPEDWINDOW)
GUISetBkColor(0x00ff00)

$btnCheckBox3=GUICtrlCreateLabel("testing",0,0,100,20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")
$btnCheckBox   = GUICtrlCreateCheckbox('Checkbox', 100, 30, 100, 20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")
$btnCheckBox2   = GUICtrlCreateRadio('radio', 100, 150, 80, 20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", " ", "wstr", " ")

; will we see the pic instead of green ... ? I don't think so ...
GUISetState()

While True

    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch

WEnd

I used your script and its perfect. you can see the green as the controls backgrounds.. but when i implemented your DllCalls into my script it didnt change anything.

Posted Image

i also tried putting my script into yours and figured out what the problem is. It's that im using a CtrlCreatePic for the background of my script, while the background itself is buttonface. so thats why the control backgrounds are buttonface instead of the picture.

how do i make the background of the controls cooperate with the picture im trying to do? apparently making them transparent fixes them with the color of the GUI instead of what color is underneath.

Share this post


Link to post
Share on other sites
picea892

Only works for checkboxs and radios....but you can do this.

#include <GUIConstants.au3>
#Include <WinAPI.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$hWndMain      = GUICreate("My CheckBox Button with Transparency", 300, 200, -1, -1,$WS_OVERLAPPEDWINDOW)
GUISetBkColor(0x00ff00)

$btnCheckBox   = GUICtrlCreateCheckbox('Checkbox', 100, 30, 12, 12)
$label   = GUICtrlCreateLabel('Checkbox', 118, 29, 122, 12)
 GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$btnCheckBox2   = GUICtrlCreateRadio('radio', 100, 150, 12, 12)
$radio   = GUICtrlCreateLabel('radio', 118, 149, 112, 12)
; will we see the pic instead of green ... ? I don't think so ...
GUISetState()

While True

    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch

WEnd

Share this post


Link to post
Share on other sites
demandnothing

ok.. thanks, but what im mostly worried about is the Slider. is there something i can do for it? or the list box?

Share this post


Link to post
Share on other sites
picea892

Last try, then I give up. Do it with two gui's, set a guictrlpic for the back gui.

Below is adapted from one of my widget examples in my signature so sorry if it is messy I did a lot of cutting.

#include <GuiConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#Include <Misc.au3>
HotKeySet("{esc}","exited")
Opt("TrayAutoPause", 0)
opt("GUIOnEventMode",1)
TraySetClick(8)

Global $nth=5 ; how many inputboxes
Global $stopit

global $dll = DllOpen("user32.dll")

Global $gwidth=500, $gheight=355,$initialpsx=200,$initialpsy=200, $rndclo

; change GUI name to change widget name
Global $Gui = GUICreate("Outlook Calendar Updater", $gwidth, $gheight,$initialpsx,$initialpsy ,$WS_POPUP,$WS_EX_TOOLWINDOW)

;;;;;;;;;;;;;;;;;register messages for background gui;;;;;;;;;;;;;;;;;;;;;;;;
    GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" ) ;sets up drag move on background and x button close


$guicontrols=GUICreate("Outlook",$gwidth, $gheight,$initialpsx,$initialpsy,$WS_POPUP,$WS_EX_LAYERED,$Gui) ;gui holding the controls
;;;;;;;;;;;below is a DLLcall register for the foreground child window;;;;;;;;;;;;;;;;
GUISetBkColor(0x00ff00)
GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "clickbuttons")

$btnCheckBox3=GUICtrlCreateLabel("testing",10,0,100,20)
GUICtrlSetBkColor(-1,0x00ff00)
GUICtrlSetColor(-1,0xffffff)
$btnCheckBox   = GUICtrlCreateCheckbox('Checkbox', 100, 30, 100, 20)
GUICtrlSetBkColor(-1,0x00ff00)
GUICtrlSetColor(-1,0xffffff)
$btnCheckBox2   = GUICtrlCreateRadio('radio', 100, 150, 80, 20)
GUICtrlSetBkColor(-1,0x00ff00)
GUICtrlSetColor(-1,0xffffff)
$btnCheckBox2   = GUICtrlCreateSlider(100, 60, 180, 20)
GUICtrlSetBkColor(-1,0x00ff00)
GUICtrlSetColor(-1,0xffffff)




GUISetBkColor(0x000000,$Gui)
        WinSetTrans($GUI,"",200)
_API_SetLayeredWindowAttributes($guicontrols, 0x00ff00, 255)
GUISetState(@SW_SHOW, $Gui)
GUISetState(@SW_SHOW, $guicontrols)
_GuiRoundCorners($Gui,0, 0, 30, 30) ; makes the background have round corners
GUISwitch($guicontrols)

While 1
    Sleep(40)
    $msg = TrayGetMsg()
    if $msg=$TRAY_EVENT_PRIMARYDOWN and WinActive($guicontrols)=0 then WinActivate($guicontrols)

WEnd


Func Drag() ;allows dragging of widget and click to exit

Local $PosDiff[2]
    While 1
        $MousePos = MouseGetPos ()
        $WinPos = WinGetPos ($Gui,"")
        $PosDiff[0] = $WinPos[0] - $MousePos[0]
        $PosDiff[1] = $WinPos[1] - $MousePos[1]
        While _IsPressed ("01", $dll)
            $MousePos = MouseGetPos ()
            WinMove ($Gui, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
            WinMove ($guicontrols, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
            $WinPos = WinGetPos ("","")
            Sleep (10)
        WEnd
        ExitLoop
        Sleep (10)
    WEnd
    ;_WinAPI_RedrawWindow($Gui,"","",BitOR($RDW_ERASE,$RDW_INVALIDATE,$RDW_UPDATENOW,$RDW_FRAME,$RDW_ALLCHILDREN))
    _WinAPI_RedrawWindow($guicontrols,"","",BitOR($RDW_ERASE,$RDW_INVALIDATE,$RDW_UPDATENOW))
EndFunc


;===============================================================================
;
; 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, $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

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long",  $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3,  "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
EndFunc ;==>_GuiRoundCorners

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×