Jump to content

Set a semi transparent background on second/child window

Recommended Posts


I would like to create a window like the one shown below. The requirements are as below

1. The title bar should be opaque.

2. The parent window/Main screen will be below the side menu/child window

3. The left side of the side menu window should be opaque.

4. The right side should be semi-transparent. 



Any idea to help?

Share this post

Link to post
Share on other sites

@siva1612 a simple search of the forum for "gui transparency" turns up a large number of threads on the subject. What have you tried on your own?

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
Share on other sites

@JLogan3o13 I have tried the following.

All the threads I searched were talking either about setting the background as completely transparent or setting the transparency of the entire window including the controls and all. None of these worked.

Though as I'm writing this reply i think can achieve this effect by using two GUIs. One on the left with an opaque background and one on the right without any controls and with its transparency level set. Will try that!

Share this post

Link to post
Share on other sites

maybe some of this code could help.

Of course a few things should change and i would suggest replacing extended GUI style with WS_EX_LAYERED like so:

$hGUI = GUICreate("", $iWidth, $iHeight, -1, -1, 0, 0x00080000)


Edited by genius257

Share this post

Link to post
Share on other sites

Here is an alternative approach. Click the button to show the overlay.

It uses a semi-transparent GUI with no controls as the 'background'.
The front GUI has the controls with a background that is completely transparent.


#include <GUIConstants.au3>
#include <WinAPI.au3>
#include <FontConstants.au3>
#include <AutoItConstants.au3>

Opt("GUIOnEventMode", 1)

Global $hgui, $hguiovl, $hguiovlbk
Global $showOverlay

;run main function

Func _main()
    Local $iGuiWidth = 500
    Local $iGuiHeight = 400
    Local $bkColor = 0x555555
    Local $alpha=200 ;0-255
    Local $iOverlayX = 150

    ;create the main GUI
    $hgui = GUICreate("main gui", $iGuiWidth, $iGuiHeight, -1, -1, -1, BITOR($WS_EX_COMPOSITED,$WS_EX_LAYERED))
    GUISetBkColor( 0x99FF99 )
    GUISetOnEvent($GUI_EVENT_CLOSE, "_onExit")

    GUICtrlCreateLabel("This is some text on bottom", 300, 150, 200)
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlCreateLabel("show/hide overlay", 10, 30, 200)
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlCreateButton("Show", 10, 50, 50, 25)
    GUICtrlSetOnEvent(-1, "_showoverlay")

    ;create the overlay background GUI
    $hguiovlbk = GUICreate("transparency test bk", $iGuiWidth-$iOverlayX, $iGuiHeight, $iOverlayX, 0, $WS_POPUP, BITOR($WS_EX_COMPOSITED,$WS_EX_LAYERED, $WS_EX_MDICHILD), $hgui)
    GUISetBkColor( $bkColor )
    WinSetTrans($hguiovlbk,"", $alpha) ;make window semi-transparent
    GUISetOnEvent($GUI_EVENT_CLOSE, "_onExit")

    ;create the overlay controls GUI
    $hguiovl = GUICreate("transparency test", $iGuiWidth-$iOverlayX, $iGuiHeight, $iOverlayX, 0, $WS_POPUP, BITOR($WS_EX_COMPOSITED,$WS_EX_LAYERED, $WS_EX_MDICHILD), $hgui)
    GUISetBkColor( $bkColor )
    _WinAPI_SetLayeredWindowAttributes($hguiovl, $bkColor, 255) ;make background fully transparent
    GUISetOnEvent($GUI_EVENT_CLOSE, "_onExit")
    GUISetFont(Default, Default, Default, "Arial", $hguiovl, 3 ) ;disable aliasing for fuzzy fonts

    GUICtrlCreateLabel("This is some text on top", 10, 10, 200)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 12)

    GUICtrlCreateLabel("This is some more text on top", 10, 50, 200)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 12)

    GUISetState(@SW_SHOW, $hgui)

    While 1

Func _showOverlay()
    If $showOverlay Then
        GUISetState(@SW_HIDE, $hguiovlbk)
        GUISetState(@SW_HIDE, $hguiovl)
        $showOverlay = 0
        GUISetState(@SW_SHOW, $hguiovlbk)
        GUISetState(@SW_SHOW, $hguiovl)
        $showOverlay = 1

Func _onExit()


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

  • Similar Content

    • therks
      By therks
      So I'm working on an application and I've hot keyed all the numbers, and for some reason this particular combination doesn't work. All the other numbers with Ctrl+Shift work fine, and all other combinations of modifiers work with 0. Has anyone else encountered this? It's very strange. 
      Guicreate('', 300, 300) $button = GUICtrlCreateButton('Button', 0, 0) Dim $accel = [ [ '^+0', $button ] ] GUIsetaccelerators($accel) Do $gm = guigetmsg()  If $gm = $button then msgbox(0,'','test') Until $gm = - 3 Sorry for the ugly code, i typed this up on my phone. 😅
    • rudi
      By rudi
      For a certain task I need to display a too long grid of controls.
      As I want to avoid to split this on multiple tabs, I'd like to use a scroll bar on the right hand side, as visible in this "manually faked" GUID below.
      Is this possible? Looking through the various GuiCtrlCreate*() functions, as well at the controls I can create using the Koda FormDesigner I couldn't see, howto...
      Regards, Rudi.

    • DoofGore
      By DoofGore
      Hello All, My first post I know this is pretty noobish but I'm trying to find a way to make this gui working.. searched but as I'm new to autoit I don't understand much... 
      I want to make this gui on top if we press ON TOP button and off on top function when we press on top off.. Created gui with koda ... any help would be appreciated 
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 353, 209, 192, 114) Global $ONTOPON = GUICtrlCreateButton("ON TOP ON", 32, 40, 137, 65) Global $exit = GUICtrlCreateButton("EXIT", 105, 118, 137, 65) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") Global $ONTOPOFF = GUICtrlCreateButton("ON TOP OFF", 184, 41, 137, 65) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ONTOPON Case $ONTOPOFF Case $exit Exit EndSwitch WEnd  

    • computergroove
      By computergroove
      I've made a form in Koda where I make a list of 3 user definable elements that I want to be able to replicate with a button press so a user can add data that can be used as part of the program. 
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=D:\Carbonite Important\0 - Programing\Scite and Autoit\Koda\Forms\Mileage Estimator.kxf $Form1 = GUICreate("Save Project", 614, 1126, 298, 141) $Location = GUICtrlCreateInput("Location", 40, 112, 345, 21) $Distance = GUICtrlCreateInput("Distance", 400, 112, 89, 21) $AddLocation = GUICtrlCreateButton("AddLocation", 288, 80, 97, 25) $Label1 = GUICtrlCreateLabel("Location", 40, 88, 45, 17) $Label2 = GUICtrlCreateLabel("Distance", 400, 88, 46, 17) $HomeBase = GUICtrlCreateInput("HomeBase", 312, 32, 121, 21) $LeapYear = GUICtrlCreateCheckbox("LeapYear", 464, 32, 17, 17) $Label3 = GUICtrlCreateLabel("Leap Year?", 488, 32, 59, 17) $Variance = GUICtrlCreateInput("Variance", 504, 112, 81, 21) $Label4 = GUICtrlCreateLabel("Variance", 504, 88, 46, 17) $Label5 = GUICtrlCreateLabel("Home Base", 312, 8, 59, 17) $Button1 = GUICtrlCreateButton("Button1", 144, 56, 1, 57) $Save = GUICtrlCreateButton("Save Project", 40, 16, 121, 25) $Load = GUICtrlCreateButton("Load Project", 176, 16, 121, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $AddLocation EndSwitch WEnd I want to press the "add location" button and have the fields {Location, Distance and variance} create a new blank record located under the existing 3 input boxes. Since the fields can number over 30 locations in some examples I am thinking about having these items in a scrolling window. What is the best way to do this and can auto it add a variable while running by pressing a button?
    • XaelloNegative
      By XaelloNegative
      I made a small blunder with my code. I created the GUI under 1920x1080 resolution however, my user is configured to ONLY 1080x720 and cannot go any further than that.
      What do you guys think is the best way to correct this one? Resolution mathematics is something that came to mind however I do not have access to his PC to check  from time to time if  my estimation is correct and the resolution on my PC doesn't go down to 1080x720.
      Please help.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.