Jump to content

partially transparent edit box - cannot get to work (solved)


Recommended Posts

I am trying to get an image showing through a edit box.  I am only successful in making the edit box totally transparent

#include-once
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <WinAPISys.au3>
#include <colorconstants.au3>


;WS_EX_TRANSPARENT
$gui = GUICreate("", 1000, 800, -1, -1, -1 , $WS_EX_LAYERED)  ; use layered to get _winapi_setlay... to work


$pic = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif", 0,0,1000, 800)
GUICtrlSetState(-1, $GUI_DISABLE)

$edit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32,200,600)
GUICtrlSetBkColor(-1,$COLOR_YELLOW)
_WinAPI_SetLayeredWindowAttributes($gui,$COLOR_YELLOW,199) ; 199 is alpha (transparency level)

GUISetState(@SW_SHOW,$gui)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else

    EndSelect
WEnd
Exit


Func Terminate()
    exit(0)
EndFunc

So I am making the edit box's background yellow then using the _WINAPI_SetLayeredWIndowAttributes command to make the yellow disappear (which it does), but the alpha level is supposed to give a bit of opaqueness to it, but its not, just making it totally transparent.  The alpha level is in fact affecting the window itself and not the edit box. I only want the edit box to be partially transparent.

Help appreciated.

 

Edited by aiter
solved
Link to comment
Share on other sites

  • Moderators

aiter,

I would use a child GUI like this:

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

$hGUI = GUICreate("", 1000, 800)

$cPic = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif", 0, 0, 1000, 800)
GUICtrlSetState(-1, $GUI_DISABLE)

GUISetState(@SW_SHOW, $hGUI)

; Create child GUI
$hChild = GUICreate("", 200, 600, 176, 32, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)

$cEdit = GUICtrlCreateEdit("First line" & @CRLF, 0, 0, 200, 600)
GUICtrlSetBkColor(-1, $COLOR_YELLOW)

; Set child transparency
WinSetTrans($hChild, "", 199)

GUISetState(@SW_SHOW, $hChild)

While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
Exit

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

it should also work without a  child GUI, using WinSetTrans with the handle of the edit):

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

$hGUI = GUICreate("", 1000, 800)

$cPic = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif", 0, 0, 1000, 800)
GUICtrlSetState(-1, $GUI_DISABLE)


$cEdit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 200, 600)
GUICtrlSetBkColor(-1, $COLOR_YELLOW)

WinSetTrans(GUICtrlGetHandle($cEdit), "", 150)

GUISetState(@SW_SHOW, $hGUI)

While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
Exit

 

Link to comment
Share on other sites

  • Moderators

jguinch,

That does not produce a transparent edit for me - it is still solid yellow.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

jguinch - just tested your code on my laptop which is windows 10 64bit and your code works. Does not work on my desktop which is windows 7 64bit.

The behaviour of the input box is a bit wonky - I found it losing data sent to the control and the resize of the window to max produces wonkiness as well (strange blobs on side which disappear when the edit box is clicked on).

The window mdi_child also has problems with resize , but I can accomodate for that using a GUIRegisterMsg($WM_SIZE, "WM_SIZE") routine.  The text is also made opaque, but I can set it to be bolder.

 

Edited by aiter
add
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

×
×
  • Create New...