Sign in to follow this  
Followers 0
Vision

Bkground Transparent

5 posts in this topic

hello!

im trying to make my gui transparent but i want just the background transparent not the controls so Winsettrans will not work in my way.

i found in the help files _WinAPI_SetLayeredWindowAttributes but it has no effect in my script, in the example it works good anyone knows why?

here is my "test" script

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WINAPI.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
Global $Cursor1, $Button1

$gui = GUICreate("Test", 300, 200, -1, -1)

GUISetStyle($WS_POPUP, -1, $gui)   ; NO BORDERS

$label = GUICtrlCreateButton("test", 30, 50, 50, 120, $BS_BITMAP)
$cursor = GUIGetCursorInfo()

_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF,255)  ; <-- Why this dont make the window transparent?

GUISetState()
AdlibRegister("_Hover_Label")

Func _Hover_Label()
    $pos = GUIGetCursorInfo()
    If $pos[4] = $label Then
        _GUICtrlButton_SetSize($label, 50, 120)
    Else
        _GUICtrlButton_SetSize($label, 20, 100)
    EndIf
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Vision,

Firstly you need to set the $WS_EX_LAYERED extended style.

Secondly, you need to set the GUI background to the colour you later make transparent.

So you end up with this (look for the <<<<<<<<< lines):

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WINAPI.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
Global $Cursor1, $Button1

$gui = GUICreate("Test", 300, 200, -1, -1)
GUISetBkColor(0xABCDEF) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetStyle($WS_POPUP, $WS_EX_LAYERED, $gui)   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$label = GUICtrlCreateButton("test", 30, 50, 50, 120, $BS_BITMAP)
$cursor = GUIGetCursorInfo()

_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF,255)  ; <-- It does now! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetState()
AdlibRegister("_Hover_Label")

Func _Hover_Label()
    $pos = GUIGetCursorInfo()
    If $pos[4] = $label Then
        _GUICtrlButton_SetSize($label, 50, 120)
    Else
        _GUICtrlButton_SetSize($label, 20, 100)
    EndIf
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
    EndSwitch
WEnd

All clear? :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

perfect!

thanks much :P

(would be good if this "trick" would be in the help file^^)

one additional mini question :x

can yo give me a tip how i can fix that the program crashes when i click something outside the program?

the array returned from GUIGetCursorInfo() does a critical ERROR

Edited by Vision

Share this post


Link to post
Share on other sites

can yo give me a tip how i can fix that the program crashes when i click something outside the program?

the array returned from GUIGetCursorInfo() does a critical ERROR

WinGetPos($GUI)

or else just use

_MouseTrap


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  
Followers 0