Jump to content
Autoseek

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

Recommended Posts

Autoseek

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

Share this post


Link to post
Share on other sites
AutoBert

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.

  • Like 1

Share this post


Link to post
Share on other sites
Autoseek

Thank you so much. That's exactly what I was looking for. Already implemented, running like a champ B)

Cheers

Autoseek

Share this post


Link to post
Share on other sites
AutoBert

Glad i could help :)

Share this post


Link to post
Share on other sites
TekWeis

Can you show an example of how to use this?

Share this post


Link to post
Share on other sites
Autoseek
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)

Share this post


Link to post
Share on other sites
TekWeis

Thank you.

I finally caught it after I posted the message. Not sure what I was thinking. 

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

×