Jump to content

Can I have a transparent GUICtrlCreateEdit box?


Orgins
 Share

Recommended Posts

Can I have a transparent GUICtrlCreateEdit box? You know still see the text but not the box.

If so how?

Also can I have it auto scroll and loop around?

If so how?

I haven't really done much but this is what I got so far:

#include <GUIConstants.au3>

$GUI1 = GUICreate("GUI1", 273, 268, 308, 220)
$Pic1 = GUICtrlCreatePic("cat1.gif", 8, 0, 257, 265)
GUICtrlSetState(-1, $GUI_DISABLE)
$Edit1 = GUICtrlCreateEdit("", 48, 16, 177, 225, $ES_AUTOVSCROLL)

If FileExists("text.ini") Then
$var = IniRead("text.ini", "text1", "1", "NotFound")
Else
    $var = "This is what it'll say if there's no .ini file."
EndIf


GUICtrlSetData(-1, $var)
GUISetState(@SW_SHOW)


While 1
sleep(500)
WEnd

All I'm trying to make is a GUI with a pic and have text scroll over it then repeat.

Edited by Orgins

I'm a newbie.Sorry if I don't reposed to your replays very fast.

Link to comment
Share on other sites

Just pseudo code here, but maybe something like this?

$parent = GUICreate('parent', 400, 400)
GUISetState()

$child = GUICreate('child', 100, 40, 0, 0, $WS_CHILD, default, $parent)
$label = GUICtrlCreateLabel('Label with lots of text', 0, 0, 100, 100)
GUISetState()

$ypos = 0
While 1
   ControlMove($child, '', $label, Default, $ypos)
   $ypos += 10
   If $ypos > 60 then $ypos = 0
WEnd
Link to comment
Share on other sites

Okay, after thinking about it I just had to whip something up. Here's what I've got.

#include <GUIConstants.au3>

$sScrollText = 'A long time ago in a galaxy' & @CRLF & _
'far, far away...' & @CRLF & _
@CRLF & _
'It is a period of civil war.' & @CRLF & _
'Rebel spaceships, striking' & @CRLF & _
'from a hidden base, have won' & @CRLF & _
'their first victory against' & @CRLF & _
'the evil Galactic Empire.' & @CRLF & _
@CRLF & _
'During the battle, Rebel' & @CRLF & _
'spies managed to steal secret' & @CRLF & _
'plans to the Empire''s' & @CRLF & _
'ultimate weapon, the DEATH' & @CRLF & _
'STAR, an armored space' & @CRLF & _
'station with enough power to' & @CRLF & _
'destroy an entire planet.' & @CRLF & _
@CRLF & _
'Pursued by the Empire''s' & @CRLF & _
'sinister agents, Princess' & @CRLF & _
'Leia races home aboard her' & @CRLF & _
'starship, custodian of the' & @CRLF & _
'stolen plans that can save her' & @CRLF & _
'people and restore' & @CRLF & _
'freedom to the galaxy...'

$parent = GUICreate('', 290, 100)
GUICtrlCreateLabel('Scrolling label example:', 5, 5, 150, 20)
GUISetState()

$child = GUICreate('', 250, 60, 20, 30, $WS_CHILD, $WS_EX_CLIENTEDGE, $parent)
GUISetBkColor(0)
$label = GUICtrlCreateLabel($sScrollText, 0, 60, 250, 510, $SS_CENTER)
GUICtrlSetFont(-1, 14)
GUICtrlSetColor(-1, 0xffff00)
GUISetState()

Global $iScrollPos = -60
AdlibEnable('Adlib', 100)

While 1
    $gm = GUIGetMsg()
    Switch $gm
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


Func Adlib()
    $iScrollPos += 1
    ControlMove($child, '', $label, 0, -$iScrollPos)
    If $iScrollPos > 510 Then $iScrollPos = -60
EndFunc

Hope you enjoy, I enjoyed making it.

Link to comment
Share on other sites

  • 2 years later...

Okay, after thinking about it I just had to whip something up. Here's what I've got.

....

Hope you enjoy, I enjoyed making it.

That was great, along time ago but nice script. Since it's older script which is using "AdlibEnable()" function it should use "AdlibRegister ( "function" [, time] )" instead. So i re-edit this script to use on AutoIt script v3.3.4.0. If...... IF someone like to use this script from RobSaunders, like i do. :mellow:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

$sScrollText = 'A long time ago in a galaxy' & @CRLF & _
'far, far away...' & @CRLF & _
@CRLF & _
'It is a period of civil war.' & @CRLF & _
'Rebel spaceships, striking' & @CRLF & _
'from a hidden base, have won' & @CRLF & _
'their first victory against' & @CRLF & _
'the evil Galactic Empire.' & @CRLF & _
@CRLF & _
'During the battle, Rebel' & @CRLF & _
'spies managed to steal secret' & @CRLF & _
'plans to the Empire''s' & @CRLF & _
'ultimate weapon, the DEATH' & @CRLF & _
'STAR, an armored space' & @CRLF & _
'station with enough power to' & @CRLF & _
'destroy an entire planet.' & @CRLF & _
@CRLF & _
'Pursued by the Empire''s' & @CRLF & _
'sinister agents, Princess' & @CRLF & _
'Leia races home aboard her' & @CRLF & _
'starship, custodian of the' & @CRLF & _
'stolen plans that can save her' & @CRLF & _
'people and restore' & @CRLF & _
'freedom to the galaxy...'

$parent = GUICreate('', 290, 100)
GUICtrlCreateLabel('Scrolling label example:', 5, 5, 150, 20)
GUISetState()

$child = GUICreate('', 250, 60, 20, 30, $WS_CHILD, $WS_EX_CLIENTEDGE, $parent)
GUISetBkColor(0)
$label = GUICtrlCreateLabel($sScrollText, 0, 60, 250, 510, $SS_CENTER)
GUICtrlSetFont(-1, 14)
GUICtrlSetColor(-1, 0xffff00)
GUISetState()

Global $iScrollPos = -60
;~ AdlibEnable('Adlib', 100)
AdlibRegister ( "Adlib", 100 )

While 1
    $gm = GUIGetMsg()
    Switch $gm
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func Adlib()
    $iScrollPos += 1
    ControlMove($child, '', $label, 0, -$iScrollPos)
    If $iScrollPos > 510 Then $iScrollPos = -60
EndFunc

Thank's for this nice script. I'm still newbie, and seem this script useful and feel thankful. :(

Edited by Basicz

[right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center]

Link to comment
Share on other sites

  • 3 years later...

Hi,

Thanks for that great script. I was wondering for months, how I'd be able to autoscroll a GUI element without having high CPU-load. This is IT! Great. I've altered the script to scroll the text sideways (I swapped the -$iScrollPos and the 0 at the ControlMove-line).

But there is another thing that I'm wondering about: How to make a kind of an 'endless' label to auto-scroll? The label should be shown continously in one direction without any stuttering or jumping. Means, that if the label's end is reached, the script should show the label's begin attached to the end  and continue scolling whitount gap in a loop, like a ticker on TV on a news channel.

Does anyone have an Idea on that?

Zoli

Link to comment
Share on other sites

  • Moderators

Zoli1972,

Look at the Marquee UDF in my sig. :)

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

M23,

I've tried the exaple script coming with your Marquee UDF. Unfortunately, something is not clear to me. Where can I set the marquee properties somehow like below?:

If the marquee text ends it begins immediately again, without leaving a one marquee element wide empty space in between.

See images. Instead of image one,

post-22219-0-63581100-1389271942_thumb.j

I'd like to have image 2.

post-22219-0-72577000-1389271973_thumb.j

Zoli

Edited by Zoli1972
Link to comment
Share on other sites

  • Moderators

Zoli1972,

As far as I know that is the normal behaviour for Marquee controls and I have no idea how to make it continuous, sorry. :(

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

M23,

I've googled a bit around and found a Java script template, which seems to be free to use:

http://javascript.about.com/library/blctmarquee2.htm

As you can see, that does the infinite scolling without gaps. Unfortunately, I don't have any Java skills at all, so I don't know how to implement that script into your UDF, and of course, wether this is possible at all or not.

If I understood correctly, you're already using a kind of little browser anyway to show the marquee. So the question is, do you have some Java script skills (as a moderator I suppose you do) and some time to try to build a funcion using that Java script? Of course only if you see any possibility of success.

Zoli

Link to comment
Share on other sites

  • Moderators

Zoli1972,

 

do you have some Java script skills

No, sorry. :)

 

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

Edit Control pure transparency isn't possible, you would only be able to draw pattern.

You seem to have missed out >this topic

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

As suggested by others, it would be better to use labels than the edit controls for this task. The following is an

Example

#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Array.au3>

;following text is given by therks.
Global $sScrollText = 'A long time ago in a galaxy' & @CRLF & _
        'far, far away...' & @CRLF & _
        @CRLF & _
        'It is a period of civil war.' & @CRLF & _
        'Rebel spaceships, striking' & @CRLF & _
        'from a hidden base, have won' & @CRLF & _
        'their first victory against' & @CRLF & _
        'the evil Galactic Empire.'

Global $iMaxLines, $Height, $hScroll, $iLineHeight, $iScrollPos, $iVisibleLinesMax, $iLabel, $Y


GUICreate('Continuous Flowing Label - Vertical || Phoenix XL', 300, 400)
GUICtrlCreateLabel('Scrolling label example:', 5, 5, 150, 20)
GUISetState()

InitializeVars(10, 30, 280, 300)

AdlibRegister('Adlib', 30)

Do
    Sleep(10)
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Func InitializeVars($iX, $iY, $iWidth, $iHeight, $iColor = 0, $iBkColor = 0xfff00f)

    Local $hParent = GetCurrentGUI_LineHt($iLineHeight)
    $iVisibleLinesMax = Floor($iHeight / $iLineHeight)
    $Height = $iHeight
    $Y = $iY

    $sScrollText = StringRegExpReplace($sScrollText, "\v+", @CRLF)
    If StringRight($sScrollText, 2) <> @CRLF Then $sScrollText &= @CRLF

    Local $Text = $sScrollText
    Do
        $iMaxLines += 1
        $Text = StringRegExpReplace($Text, "\v+", "", 1)
    Until @extended = 0

    ModifyText($sScrollText, $iHeight)

    $hScroll = GUICreate('ScrollWin', $iWidth, $iHeight, $iX, $iY, $WS_CHILD, -1, $hParent)
    GUISetBkColor($iBkColor)
    GUICtrlSetDefColor($iColor)

    $iLabel = GUICtrlCreateLabel($sScrollText, 0, $iHeight, $iWidth, $iLineHeight * $iMaxLines, $SS_CENTER)
    GUICtrlCreateLabel($sScrollText, 0, $iHeight, $iWidth, $iLineHeight * $iMaxLines, $SS_CENTER)

    GUISetState()
    GUISwitch($hParent)

EndFunc   ;==>InitializeVars

Func ModifyText(ByRef $sText, $iHeight)

    Local $iTotalHeightofText = $iLineHeight * $iMaxLines
    Local $Text = @CRLF & $sText

    While $iTotalHeightofText < $iHeight
        $iTotalHeightofText += $iLineHeight * $iMaxLines
        $sText &= $Text
    WEnd

    $iMaxLines *= $iTotalHeightofText / ($iLineHeight * $iMaxLines)

EndFunc   ;==>ModifyText

Func GetCurrentGUI_LineHt(ByRef $Height)

    Local $iLabel = GUICtrlCreateLabel("", -10, -10, 1, 1)
    $Height = GetLineHeight(GUICtrlGetHandle(-1))

    Local Const $hRet = _WinAPI_GetParent(GUICtrlGetHandle(-1))
    GUICtrlDelete($iLabel)

    Return $hRet

EndFunc   ;==>GetCurrentGUI_LineHt

Func Adlib()

    Static $iLinepassed = 1, $frec, $iCount, $1 = 2, $2 = 0 ;0 = stopped, 1 = moving, 2 = moving and the main

    Local $aPos = ControlGetPos($hScroll, "", $iLabel), $aPos1 = ControlGetPos($hScroll, "", $iLabel + 1)
    If $1 Then ControlMove($hScroll, '', $iLabel, 0, $aPos[1] - $Y - 1)
    If $2 Then ControlMove($hScroll, "", $iLabel + 1, 0, $aPos1[1] - 1 - $Y)

    If $1 = 2 Then
        If ($Height - $aPos[1] + $Y) > $iLinepassed * $iLineHeight Then $iLinepassed += 1
    ElseIf $2 = 2 Then
        If ($Height - $aPos1[1] + $Y) > $iLinepassed * $iLineHeight Then $iLinepassed += 1
    EndIf

    If $iLinepassed > $iMaxLines Then
        If $2 = 0 Then $2 = 1
        _ArraySwap($1, $2)
        $iLinepassed = 1
        $iCount += 1
        $frec = True
    EndIf

    If $iCount > 1 And $frec Then
        ControlMove($hScroll, "", $iLabel + Mod($iCount, 2), 0, $Height + $Y)
        $frec = False
    EndIf

EndFunc   ;==>Adlib

Func GetLineHeight($hCtl)
    ; Create DC
    $hDC = _WinAPI_GetDC($hCtl)
    $hFont = _SendMessage($hCtl, $WM_GETFONT) ; $WM_GetFont
    $hPrev_Font = _WinAPI_SelectObject($hDC, $hFont)

    Local $tSize = DllStructCreate("int;int")

    DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", "¤", "int", 1, "ptr", DllStructGetPtr($tSize))

    _WinAPI_SelectObject($hDC, $hPrev_Font)
    _WinAPI_ReleaseDC($hCtl, $hDC)

    Return DllStructGetData($tSize, 2)
EndFunc   ;==>GetLineHeight

Regards :)

Phoenix XL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Why not create a animated GIF image that loops and embed that?

Try this >UDF and something like this (modified the example and quickly made the gif so not the best)

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

Opt("MustDeclareVars", 1)

; Start by choosing GIF to display
Global $sFile = "C:\Users\Jamie\Desktop\Fraser\Apps\Dev\Autoit Forum stuff\test.gif"
If @error Then Exit

; Make GUI
Global $hGui = GUICreate("GIF Animation", 54, 60, -1, -1, $WS_OVERLAPPEDWINDOW)

; Add some buttons
Global $hButton = GUICtrlCreateButton("&Pause animation", 10, 30, 100, 20)

; Make GIF Control
Global $hGIF = _GUICtrlCreateGIF($sFile, "", 0, 0, 54, 20)
If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE)
GUICtrlSetTip($hGIF, "Image")

; Additional processing of some windows messages (for example)
GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT
GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT

Global $iPlay = 1

; Show it
GUISetState()

; Loop till end
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hButton
            If $iPlay Then
                If _GIF_PauseAnimation($hGIF) Then
                    $iPlay = 0
                    GUICtrlSetData($hButton, "Resume animation")
                EndIf
            Else
                If _GIF_ResumeAnimation($hGIF) Then
                    $iPlay = 1
                    GUICtrlSetData($hButton, "Pause animation")
                EndIf
            EndIf
    EndSwitch
WEnd


Func _Refresh($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _GIF_RefreshGIF($hGIF)
EndFunc ;==>_Refresh

Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _GIF_ValidateGIF($hGIF)
EndFunc ;==>_ValidateGIFs

This is the gif

9d5d.gif

Just a thought!!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...