Jump to content

How to make text GUI with scroll bar for progress logging?


Autoseek
 Share

Recommended Posts

Hi everyone,

I assume that this has already been solved, but my search for "GUI log(ging) window" did not return useful results. So, if available, a simple pointer to an exisiting solution is perfectly fine.

I am an "old school" guy of progress logging, i.e., I am using tons of "ConsoleWrite" statements to indicate the current state, e.g., "Copying ABC to DEF...". Obviously, when I run the executable stand-alone, the output goes nowhere. Therefore, I would like to create a text GUI with scroll bar into which I can fire off the strings that are now contained in the "ConsoleWrite" statements. Perhaps worded differently, I would like to have the functionality of the SciTE-editor in a GUI, without having to put major efforts into just programming this functionality. I assume I am not the first one who needs this :D

Thank you for any suggestions.

Cheers

Autoseek

Link to comment
Share on other sites

You can use

$hLog = _GUICtrlEdit_Create($mainGui,'',8, 5, 467, 314, BitOR($WS_HSCROLL, $WS_VSCROLL,  $ES_MULTILINE, $ES_WANTRETURN, $ES_READONLY))

as Control showing the loglines and

Func _report($sMsg, $hLog = 0, $iDebug = 0)
    ;===============================================================================
    ; Autor(s):         AutoBert (www.autoit.de)
    ;
    ; modified:         durch/Grund hier anfügen
    ;===============================================================================
    If $hLog <> 0 Then _GUICtrlEdit_AppendText($hLog, $sMsg & @CRLF)
    If $iDebug Then ConsoleWrite($sMsg & @CRLF)
    ;If $G__hFileLog > 0 Then _FileWriteLog($G__hFileLog, $sMsg & @CRLF)
EndFunc   ;==>_report

to append a line.

Link to comment
Share on other sites

  • 1 year later...
On 8.4.2018 at 9:28 PM, TekWeis said:

Can you show an example of how to use this?

Hmmm, I am afraid there is not really more to this than AutoBert has posted. This is what I did specifically. You create the container (CtrlEdit):

$hLog = _GUICtrlEdit_Create($mainGUI, '', 8, 5, 467, 314, BitOR($WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN, $ES_READONLY))

And later in your program you write into that container:

_GUICtrlEdit_AppendText($hLog, $sMsg & @CRLF)

That's all there is to it. In case it helps, here is the full GUI that I used:

$mainGUI = GUICreate("Progress", 480, 372)
$hLog = _GUICtrlEdit_Create($mainGUI, '', 8, 5, 467, 314, BitOR($WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN, $ES_READONLY))
$hCur = GUICtrlCreateLabel($mainGUI, 12, 330, 467, 20)
GUICtrlSetData($hCur, "Running...")
GUISetState(@SW_SHOW)
Link to comment
Share on other sites

  • 2 weeks later...

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