Jump to content

Customize GUI label


topten
 Share

Recommended Posts

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

 

Link to comment
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.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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

Link to comment
Share on other sites

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
Link to comment
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

 

Link to comment
Share on other sites

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

 

Link to comment
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

 

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...