Jump to content

show text as graphic or image in GUI

Recommended Posts

hello autoit team
please i've a question for you.
am creating a audio player
and in this audio player i want to show the current trac info
such as the total time and the position ... etc
i know i can show it as label
but the screen reader for the blind read the text every change
because it have a screen scan
what i want is to show this informations but such image or icon
i mean i need to create
GUICtrlCreatepic or GUICtrlCreateicon ....
or some thing as that
and show this informations as image on it
i think that i can do that with the 
_GDIPlus functions
but i couldn't find the currect way to do it
i tried the _GDIPlus_GraphicsDrawString
but i couldn't know how it work
what i need is a small example that create a GUI
and add a multy line text to it as graphic or image.
so i need a simple way because it will changed every sec
i hope any one can help me to do that

global $GUI = GUICreate("text", 400, 400)
global $label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380)
until GUIGetMSG() = -3
func GetText()
return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50")


Link to comment
Share on other sites

Hi @nacerbaaziz

Something like this?

#include <GDIPlus.au3>

Opt("GuiOnEventMode", 1)

$bRun = True
$iIndex = 0

Global $aTexts = ["Hello world"&@CRLF&"This is a test", "easy"&@CRLF&"peacy", "third"&@CRLF&"option"]

$hWnd = GUICreate("", 700, 320)
GUISetState(@SW_SHOW, $hWnd)

GUISetOnEvent(-3, "MyExit", $hWnd)

$iLabel = GUICtrlCreateLabel("", 10, 10, 380, 100)
GUICtrlSetBkColor($iLabel, 0xFFFF0000)

;MsgBox(0, "", GUICtrlGetHandle($iLabel))
$hGraphics = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($iLabel))
;$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(0, 0, 100, 200)

$hTimer = TimerInit()

While $bRun
    If TimerDiff($hTimer) > 1000 Then
        $hTimer = TimerInit()
        $iIndex = Mod($iIndex + 1, UBound($aTexts))

        _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
        _GDIPlus_GraphicsDrawStringEx($hGraphics, $aTexts[$iIndex], $hFont, $tLayout, $hFormat, $hBrush)


Func MyExit()
    $bRun = False


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

  • Create New...