Sign in to follow this  
Followers 0
enkriptix

Transparent Window Background

11 posts in this topic

I want to be able to show a window with an image and a line of text, but have the background be completely transparent, so it looks like the image and text are "floating" on the desktop. Any suggestions?


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites



GUICtrlSetBkColor ( controlID, $GUI_BKCOLOR_TRANSPARENT )

Share this post


Link to post
Share on other sites

GUICtrlSetBkColor ( controlID, $GUI_BKCOLOR_TRANSPARENT )

I tried that, but I couldn't get it to work properly. Could you give an example of a transparent window with a floating image, or something, please?


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

I tried that, but I couldn't get it to work properly. Could you give an example of a transparent window with a floating image, or something, please?

Maybe this (by martin) will get you started:

http://www.autoitscript.com/forum/index.ph...st&p=454249

Share this post


Link to post
Share on other sites

Try this for Example

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "Terminate")

Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\logo4.gif"
$pic = GUICreate("test", 169, 68, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$basti_stay = GUICtrlCreatePic($sFile, 0, 0, 169, 68,-1, $GUI_WS_EX_PARENTDRAG)
$hDC = GUICtrlCreateLabel("This is text on a transparent Layered GUI",0, 0, 200, 20 )
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
Do
    $msg = GUIGetMsg()
    
Until $msg = $GUI_EVENT_CLOSE

Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites

Try this for Example

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "Terminate")

Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\logo4.gif"
$pic = GUICreate("test", 169, 68, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$basti_stay = GUICtrlCreatePic($sFile, 0, 0, 169, 68,-1, $GUI_WS_EX_PARENTDRAG)
$hDC = GUICtrlCreateLabel("This is text on a transparent Layered GUI",0, 0, 200, 20 )
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
Do
    $msg = GUIGetMsg()
    
Until $msg = $GUI_EVENT_CLOSE

Func Terminate()
    Exit 0
EndFunc
Fantastic! Thanks, Tec!

Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

Just a few more questions:

How can I keep the window behind all other windows?

Is there any way I can "trim" or "defringe" the image when it shows, because it shows a jagged white outline (even though the image itself has none)?

Can I change the text color? If so, how?

Can I make it so that if a user right-clicks the image, a menu appears?

Thanks a lot for all the help!


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

hmm dont now if it is perfekt, but it works i think.

if someone find a misstake, correct it please

#include <Constants.au3>
#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global Enum $idOpen = 1000, $idSave, $idExit
Global $hWndProc, $hFunc


_Main()

Func _Main()
    Local $hGUI, $Button, $hDC, $pic
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\logo4.gif"

   ; Create GUI
    $hGUI = GUICreate("Menu", 169, 68, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    $pic = GUICtrlCreatePic($sFile, 0, 0, 169, 68, -1, $GUI_WS_EX_PARENTDRAG)   
    $hWndProc = _WinAPI_GetWindowLong(GUICtrlGetHandle($pic), $GWL_WNDPROC)
    $hFunc = DllCallbackRegister('Button_WindowProcefure', 'long', 'hwnd;uint;wparam;lparam')
    _WinAPI_SetWindowLong(GUICtrlGetHandle($pic), $GWL_WNDPROC, DllCallbackGetPtr($hFunc))  
    $hDC = GUICtrlCreateLabel("This is text",0, 0, 169, 20 )
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xff00ff )
    GUISetState()

   ; Register message handlers
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")

   ; Loop until user exits
    Do
            Sleep( 10 )
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    DllCallbackFree($hFunc)     
EndFunc  ;==>_Main

; Handle WM_COMMAND messages
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Switch $iwParam
        Case $idOpen
            _WinAPI_ShowMsg ("Open")
        Case $idSave
            _WinAPI_ShowMsg ("Save")
        Case $idExit
            _WinAPI_ShowMsg ("Info")
    EndSwitch
EndFunc  ;==>WM_COMMAND

; Handle WM_CONTEXTMENU messages
Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hMenu

    $hMenu = _GUICtrlMenu_CreatePopup ()
    _GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Open", $idOpen)
    _GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Save", $idSave)
    _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Exit", $idExit)
    _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam)
    _GUICtrlMenu_DestroyMenu ($hMenu)
    Return True
EndFunc  ;==>WM_CONTEXTMENU

Func Button_WindowProcefure($hWnd, $iMsg, $iwParam, $ilParam)
    If $iMsg = $WM_COMMAND Then
        Switch _WinAPI_LoWord($iwParam)
            Case $idOpen
                _WinAPI_ShowMsg("Child Open")
            Case $idSave
                _WinAPI_ShowMsg("Child Save")
            Case $idExit
                Exit
        EndSwitch
    EndIf

    Return _WinAPI_CallWindowProc($hWndProc, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc   ;==>Button_WindowProcefure

Share this post


Link to post
Share on other sites

hmm dont now if it is perfekt, but it works i think.

if someone find a misstake, correct it please

Works great! Thanks again, Tec!


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

enkriptix,

In future, please do not post the same question in different areas of the forum. I would then not have wasted my time answering this one.

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

#11 ·  Posted (edited)

I think you could benefit from this thread: >link

EDIT: bringing up a 6 year thread might be a little old, creating your own topic might have been a better idea. :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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