Jump to content

GUI Transparent background only.


Recommended Posts

Im looking for a way to make the background transparent, but keep the graphic fully visible.

My GUI:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#include <ColorConstantS.au3>


$Form1 = GUICreate("Form1", 200, 200, 663, 317)

GUICtrlCreateGraphic(0, 100, 200, 1)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(0, 50, 200, 1)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(0, 150, 200, 1)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(100, 0, 1, 200)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(50, 0, 1, 200)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(150, 0, 1, 200)
GUICtrlSetBkColor(-1, 0x000000)

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I tried this so far, but that dont even work :-/

$Form1 = GUICreate("Form1", 200, 200, 663, 317)
GUISetState(@SW_SHOW)
_WinAPI_SetLayeredWindowAttributes($Form1, 0x0000F4, 255)

Also tried with "WinSetTrans" But that makes everything transparent :-/

$Form1 = GUICreate("Form1", 200, 200, 663, 317)
GUISetState(@SW_SHOW)
WinSetTrans($Form1, "", 70)

Also just tried this:

$Form1 = GUICreate("Form1", 200, 200, 663, 317)
$bk = GUICtrlSetBkColor($form1, 0x000000)

WinSetTrans($bk, "", 70)

Also:

$Form1 = GUICreate("Form1", 200, 200, 663, 317)
$bk = GUISetBkColor($COLOR_RED)
WinSetTrans($bk, "", 70)

Nothing i tried so far have worked.

Edited by GraaF1337
Link to comment
Share on other sites

Mikell's code works for me.

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

$Form1 = GUICreate("Form1", 200, 200, 663, 317, -1, $WS_EX_LAYERED)
GUISetBkColor(0x0000F4)
_WinAPI_SetLayeredWindowAttributes($Form1, 0x0000F4)


GUISetState()

Do 
    Sleep(10)
Until GUIGetMsg() = -3
Link to comment
Share on other sites

 

Mikell's code works for me.

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

$Form1 = GUICreate("Form1", 200, 200, 663, 317, -1, $WS_EX_LAYERED)
GUISetBkColor(0x0000F4)
_WinAPI_SetLayeredWindowAttributes($Form1, 0x0000F4)


GUISetState()

Do 
    Sleep(10)
Until GUIGetMsg() = -3

Yea, i figured out why it didn't for me.. :-/

If you add a picture somewhere in the GUI all of the transparent will become blue. :(

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#include <ColorConstantS.au3>


$Form1 = GUICreate("Form1", 200, 200, 663, 317, -1, $WS_EX_LAYERED)
GUISetBkColor(0x0000F4)
_WinAPI_SetLayeredWindowAttributes($Form1, 0x0000F4)

GUICtrlCreateGraphic(0, 100, 200, 1)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(0, 50, 200, 1)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(0, 150, 200, 1)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(100, 0, 1, 200)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(50, 0, 1, 200)
GUICtrlSetBkColor(-1, 0x000000)

GUICtrlCreateGraphic(150, 0, 1, 200)
GUICtrlSetBkColor(-1, 0x000000)

$Pic1 = GUICtrlCreatePic("C:\Users\Toft\Desktop\dot.bmp", 50, 50, 100, 100)

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

1a0a6373865f3f435ad27fdfa5e7008d.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...