Sign in to follow this  
Followers 0
qwert

Need transparent background for scrollable text

8 posts in this topic

I've tried several methods to fashion a block of scrollable text on top of an image.  If it's just a block of text, the $GUI_BKCOLOR_TRANSPARENT flag works, of course.

I realize I may have structured the GUI wrong for what I trying to do.  But I haven't been able to find a different way that keeps the buttons, selections and drag parent working properly.

Thanks for any help.

;
;       Test to scroll text on top of an image
;

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

$hGUI = GUICreate("Scroll On Image", 800, 600, Default, Default, BitOR($WS_BORDER, $WS_POPUP))
GUICtrlCreateLabel("Text On Image", 8, 6, 140, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 14, 700, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
$button = GUICtrlCreateButton("Button", 640, 110, 100, 24)
    GUICtrlSetResizing(-1, $GUI_DOCKRIGHT)
$close = GUICtrlCreateLabel("X", 766, 10, 24, 24)
    GUICtrlSetFont(-1, 16, 400, 0, "Lucida Sans Unicode")
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetResizing(-1, $GUI_DOCKRIGHT)
GUISetState()

GUICtrlCreatePic("C:\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 500, 600, -1, $GUI_WS_EX_PARENTDRAG)   ; put up the panel graphic

;$hScroll = GUICreate("", 560, 516 - 40, 20, 60, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_TRANSPARENT), $hGUI) ; $WS_EX_TRANSPARENT doesn't solve problem
$hScroll = GUICreate("", 560, 516 - 40, 20, 60, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)

$hdg1 = GUICtrlCreateLabel("Text should scroll on top of the image", 40, 120, 400, 24)
GUICtrlSetFont(-1, 14, 700, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$hdg2 = GUICtrlCreateLabel("Text should have a transparent background", 40, 320, 400, 24)
GUICtrlSetFont(-1, 14, 700, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetResizing(-1, $GUI_DOCKALL)

GUISetState()

$iMaxScroll = 2000
_GUIScrollbars_Generate($hScroll, 0, $iMaxScroll)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            MsgBox(0, "Esc", "Pressed", 1)
            Exit
        Case $close
            MsgBox(0, "Close", "Close requested", 1)
            Exit
        Case $hdg1
            MsgBox(0, "Selection", "First text selected", 1)
        Case $hdg2
            MsgBox(0, "Selection", "Second text selected", 1)
        Case $button
            MsgBox(0, "Button", "Pressed", 1)
   EndSwitch
WEnd

 

Text On Image.PNG

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

  • You use GUIScrollbars_Ex.au3, as this is no standard include please attach to the opening post.
  • Pictures should be disabled if other clickable controls are overlapping.
  • Your real problem is your 2. Gui

Here a small example showing 2 different scrolling labels on background picture:

;https://autoit.de/index.php/Thread/26518-Text-bewegen-und-wechseln-lassen/?postID=215148#post215148
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Global $iPos = 0, $sText = 'Das ist der Text, der immer wieder durchläuft! Viel Spass damit!'
Global $hGui, $idLblMove, $idLblText
_Example()

Func _Example()
    $hGui = GUICreate('my gui', 200, 100)
    Local $sAutoItPath = StringReplace(StringReplace(@AutoItExe, '_x64', ''), 'autoit3.exe', '')
    GUICtrlCreatePic($sAutoItPath & "Examples\GUI\msoobe.jpg", 0, 0, 500, 600, -1, $GUI_WS_EX_PARENTDRAG) ; put up the panel graphic
    GUICtrlSetState(-1, $GUI_DISABLE)

    $idLblMove = GUICtrlCreateLabel($sText, 10, 10, 180, 30)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $idLblText = GUICtrlCreateLabel($sText, 10, 50, 180, 15, $SS_LEFTNOWORDWRAP)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    _TextMarquee()
    GUISetState()
    AdlibRegister('_TextMarquee', 1000)
    AdlibRegister('_MoveMarquee', 1000)
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd
EndFunc   ;==>_Example

Func _TextMarquee()
    GUICtrlSetData($idLblText, StringMid($sText, $iPos) & " " & $sText)
    $iPos += 1
    If $iPos > StringLen($sText) Then $iPos = 0
EndFunc   ;==>_TextMarquee

Func _MoveMarquee()
    Local $aPos = ControlGetPos($hGui, '', $idLblMove)
    Local $aWin = WinGetPos($hGui)
    If $aPos[0] < $aPos[2]*-1 Then $aPos[0] = $aWin[2]
    ControlMove($hGui, '', $idLblMove, $aPos[0] - 10, $aPos[1])
EndFunc

 

Edited by AutoBert

Share this post


Link to post
Share on other sites
8 hours ago, AutoBert said:

You use GUIScrollbars_Ex.au3, as this is no standard include please attach to the opening post.

Sorry for the oversight.  Here's a link to Melba23's UDF: UDF post (see Scrollbars.zip at the bottom)

I will try your examples.  Thanks for your response.

 

Share this post


Link to post
Share on other sites
8 hours ago, AutoBert said:

Your real problem is your 2. Gui

After running your example, I realize that I had already looked at examples of marque text scrolling.

My situation is different, in that I have a large block of text that must have a vertical scroll bar.  But I will readily admit that it might not be possible, given the way windows handles "merging" of layers at runtime.

I may have to take a different approach.  Again, thanks for your response.

 

No scroll bars.PNG

Share this post


Link to post
Share on other sites

@qwert: try these lines:

...
$hScroll = GUICreate("", 560, 516 - 40, 20, 60, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $hGUI)
GUISetBkColor(0x7F8081, $hScroll)
_WinAPI_SetLayeredWindowAttributes($hScroll, 0x7F8081)
...

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

@UEZ: Thank you!

Actually, one of my early attempts tried setting the background color transparent.  But I now realize that I had $WS_EX_LAYERED defined for $hGUI and not for the child scroll panel.  Now that you've shown me the way, I'll go back and read the msdn page for layered windows and (maybe) gain a better understanding.

I do have one related question that you might be able to answer: Why does the label "Text On Image" disappear when the GUI is minimized and then returned to normal?  All other elements are restored just fine.  (I suspect it has something to do with layering.)

I appreciate your help.

Works.png

 

Share this post


Link to post
Share on other sites
15 hours ago, qwert said:

I do have one related question that you might be able to answer: Why does the label "Text On Image" disappear when the GUI is minimized and then returned to normal?  All other elements are restored just fine.  (I suspect it has something to do with layering.)

Because the pic control will be the topmost after refresh of the window and thus overlap the label.

 

Just move the label code just after the pic line:

...
GUISetState()

GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 500, 600, -1, $GUI_WS_EX_PARENTDRAG) ; put up the panel graphic
GUICtrlCreateLabel("Text On Image!", 8, 6, 140, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 14, 700, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)

;$hScroll = GUICreate("", 560, 516 - 40, 20, 60, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_TRANSPARENT), $hGUI) ; $WS_EX_TRANSPARENT doesn't solve problem
...

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Yes, that worked.  I was aware that the order affected how elements were displayed (or not displayed) initially.  But I've never considered the refresh operation.  I thought if they displayed once, they would redisplay the same way.  This demonstrates and clarifies the different operations.

Thanks very much for you assistance.

 

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