topten

Customize GUI label

9 posts in this topic

I read a text from file

$readfile = FileRead("mytext.txt")
$aOutPut1 = StringRegExp($readfile, '>(.*?)<', 3)
Global $messageproj = $aOutPut1[0]
Global $messageproj2 = $aOutPut1[2]

As a result I have this text in var:  "Line 1" & @CRLF & "Line 2" & @CRLF & "Line 3"

Then later I am trying to display the information on the gui

$label = GUICtrlCreateLabel($aOutPut1[2], 25, 30, 480, 140)

My idea is display it this way

Line1
Line2
Line3

But instead I am still getting this

"Line 1" & @CRLF & "Line 2" & @CRLF & "Line 3"

Can it work this way?

Line1
Line2
Line3

 

Share this post


Link to post
Share on other sites



you can have either a multiline label (search the forum for examples), or an Edit control - possibly with customized background color and borders, and with $ES_READONLY style. personally i find the latter easier.

Share this post


Link to post
Share on other sites

topten,

Verify the content of your variables.  For more help post a runnable reproducer.  This works for me...

#include <GUIConstantsEx.au3>

local $var = "Line 1" & @CRLF & "Line 2" & @CRLF & "Line 3"

local $gui010 = guicreate('',200,200)
local $lbl010 = guictrlcreatelabel($var,0,0,200,200)
guisetstate()

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
    EndSwitch
WEnd

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you, kylomas, I understand what you mean, but if you do it this way:

#include <GUIConstantsEx.au3>

$var = FileRead ("save1.txt"); in the file I have record "Line 1" & @CRLF & "Line 2" & @CRLF & "Line 3"
local $gui010 = guicreate('',200,200)
local $lbl010 = guictrlcreatelabel($var,0,0,200,200)
guisetstate()
while 1
   switch guigetmsg()
   case $gui_event_close
      Exit
   EndSwitch
   WEnd

Then it won't work. May be I should use some different way of data reading?

Edited by topten

Share this post


Link to post
Share on other sites

post-86910-0-08709400-1423580427_thumb.p

worked for me as shown.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Heh, Fantastic! Thanks a lot MikahS. Just in case if you know, How did it consider the line break from the txt file and ignored @CRLF to be used then as a part of the code after having been read from the file?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I did nothing out of the ordinary. here is the code I used to show you that example. :)

#include <GUIConstantsEx.au3>


Local $var = FileRead("C:\Users\STAT001\Desktop\body.txt")
Local $gui010 = GUICreate('', 200, 200)
Local $lbl010 = GUICtrlCreateLabel($var, 0, 0, 200, 200)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
    EndSwitch
WEnd

So, I would think it would work with your file. If it still doesn't, any chance you could reproduce a similar file that shows this behavior?

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Yes, it works for me too! Thanx!

Share this post


Link to post
Share on other sites

Glad it works. :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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