Sign in to follow this  
Followers 0
billthecreator

Edit Transparency?

2 posts in this topic

is there a way to set an Edit box to be transparent. and maybe keep the text not transparent?

in my gui i have a picture as the background, i wanted to see the picture behind the edit...


[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites



is there a way to set an Edit box to be transparent. and maybe keep the text not transparent?

in my gui i have a picture as the background, i wanted to see the picture behind the edit...

You could do it something like this.

#include <GUIConstants.au3>
#include <windowsconstants.au3>

#region - GUI Create
Global $Topx = 300,$Topy = 400,$extMsg
Global $Plusx = 15, $Plusy = 70
Global $gui1 = GUICreate("Parent GUI", 300, 300, $Topx, $Topy)
GUISetFont(6)
GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 300, 300)

GUISetState()
;create layered window so we can have a transparent colour which will be applied to edit background as well as the window
Global $gui2 = GUICreate("child", 200, 250, $Topx + 15,$Topy + 70, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED));$WS_EX_COMPOSITED = 0x2000000
GUICtrlCreateEdit("", 0, 0, 200, 250)
GUICtrlSetBkColor(-1, 0xABCDEF);set background to a special colour
$text = FileRead(@ScriptFullPath)
GUICtrlSetData(-1, $text)
_API_SetLayeredWindowAttributes($gui2,0xABCDEF,255);set special colour fully transparent
GUISetState()
winsetontop($gui2,'',1)
GUIRegisterMsg($WM_MOVE,"Follow")
#endregion

#region - GUI SelectLoop
While 1
    $extMsg = GUIGetMsg(1)
    $msg = $extMsg[0]
    Switch $extMsg[1]
        Case $gui1
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    Exit
            
            EndSelect
        
    EndSwitch
WEnd
#endregion


;===============================================================================
;
; 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 = 255, $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 Follow($hWnd)
    Local $wp = WinGetPos($gui1)
    If $hWnd = $gui1 then WinMove($gui2,"",$wp[0] + $Plusx, $wp[1] + $Plusy)
    
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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