Sign in to follow this  
Followers 0
the_lord_mephy

Add text to readonly Edit

11 posts in this topic

Is there a way to add a line of text to a readonly Edit?


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites



Ofcourse.

Here's an example.

#include <GUIConstants.au3>
AutoItSetOption("TrayIconDebug", 1)

;Initialize variables
Global $style1
Global $IniFile
Global $GUIWidth
Global $GUIHeight

$GUIWidth = 250
$GUIHeight = 250

GUICreate("New GUI", $GUIWidth, $GUIHeight)
$Edit_1 = GUICtrlCreateEdit("", 10, 10, 230, 200, $ES_READONLY)
$Button_1 = GUICtrlCreateButton("Test", 80, 220, 70, 20)
   
GUISetState(@SW_SHOW)

While 1
   Sleep(25)
   $msg = GUIGetMsg()
   Select
   
      Case $msg = $GUI_EVENT_CLOSE
         GUIDelete()
         Exit

      Case $msg = $Button_1
         GUICtrlSetData($Edit_1, "Some text...")

   EndSelect

WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yeah, I knew how to change the text but what I wanted to know was, is there a way to add a line of text to an Edit. For example:

Program started (Then a few minutes later it does something)

Something began (A few minutes later it does something else)

Something else done

etc.

So the edit would look like this:

----------------------
|  Program started     |
|  Something began     |
|  Something else done |
|______________________|

Sorry, I should have been clearer.

Edited by the_lord_mephy

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

Yeah, I knew how to change the text but what I wanted to know was, is there a way to add a line of text to an Edit. For example:

Program started      (Then a few minutes later it does something)

Something began    (A few minutes later it does something else)

Something else done

etc.

So the edit would look like this:

----------------------
|  Program started     |
|  Something began     |
|  Something else done |
|______________________|

Sorry, I should have been clearer.

Read the current text and then append a newline and the new text and then change the edit control to that.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks, works perfectly:)

Edit:

Heh, I made a very simple function for it:

Func _EditAppendText($editname, $data)
   $a = GuiRead($editname)
   GuiCtrlSetData($editname, $a & $data)
EndFunc
Edited by the_lord_mephy

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

easier just change the following line

GUICtrlSetData($Edit_1, "Some text...",1)
:)

Share this post


Link to post
Share on other sites

Hi guys !

I recently made my first script copying some files and then modifying content from them. Any action is logged in a text file created using _Filewritelog. It's working OK but now I'd like to display the refreshed content of the logfile into my GUI each time a new line is added. How could I replace the line

"GUICtrlSetData($Edit_1, "Some text...")"

appearing in your script with the refreshed content of my log file ? Thanks for responding :)

Share this post


Link to post
Share on other sites

Hi guys !

I recently made my first script copying some files and then modifying content from them. Any action is logged in a text file created using _Filewritelog. It's working OK but now I'd like to display the refreshed content of the logfile into my GUI each time a new line is added. How could I replace the line appearing in your script with the refreshed content of my log file ? Thanks for responding :)

Welcome to the forums :)

Assuming you want to write the whole comtents of the log file to the edit then

GuiCtrlSetData($Edit_1,FileRead($PathToLogFile))


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks for answering me, Martin !

Thanks to your explanation, my logfile's content is now displayed in my GUI. But I'm facing a problem with refreshment of that display : what I wanted to do is displaying the new content of the log file each time a line is written in it, i-e :

LOGFILE: 1:30 PM line 1 added

>> GUI: 1:30 PM line 1 displayed

and then

LOGFILE: 1:31 PM line 2 added

>> GUI: 1:31 PM line 1 + line 2 displayed

I haven't got a clue about how to do that ! :) Any suggestion ?

Share this post


Link to post
Share on other sites

Thanks for answering me, Martin !

Thanks to your explanation, my logfile's content is now displayed in my GUI. But I'm facing a problem with refreshment of that display : what I wanted to do is displaying the new content of the log file each time a line is written in it, i-e :

LOGFILE: 1:30 PM line 1 added

>> GUI: 1:30 PM line 1 displayed

and then

LOGFILE: 1:31 PM line 2 added

>> GUI: 1:31 PM line 1 + line 2 displayed

I haven't got a clue about how to do that ! :) Any suggestion ?

Not sure from what you said that I know what you want.

If you want to display only what's newer than is already shown in the edit then you could do something like this-

$Logtext = FileRead($logfile)

$Displayedtext = GuiCtrlRead($Edit_1)

GuiCtrlSetData(StringReplace($logtext,$Displaytext,''))


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Not sure from what you said that I know what you want.

If you want to display only what's newer than is already shown in the edit then you could do something like this-

$Logtext = FileRead($logfile)

$Displayedtext = GuiCtrlRead($Edit_1)

GuiCtrlSetData(StringReplace($logtext,$Displaytext,''))

Yes, that's it ! :)

It's working fine now !

Thanks a lot for your help, Martin !

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