ConsoleWrite() to GUICtrl element

瘦欲@ 提交于 2019-12-11 14:14:43

问题


How can I put ConsoleWrite() into GUICtrlCreateEdit()?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("Test", 257, 182, 192, 124)
GUISetFont(12, 400, 0, "Times New Roman")
$test = GUICtrlCreateEdit("", 8, 40, 241, 90, $ES_AUTOVSCROLL)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

ConsoleWrite('Text test')

回答1:


As per Documentation - Function Reference - GUICtrlSetData():

Modifies the data for a control.

Example:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Test", 257, 182, 192, 124)
$test = GUICtrlCreateEdit("", 8, 40, 241, 90, $ES_AUTOVSCROLL)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUICtrlSetData($test, 'Shutting down in 5 seconds ...')
            Sleep(5 * 1000)
            Exit
    EndSwitch
WEnd

How can I put ConsoleWrite() into GUICtrlCreateEdit()?

Example:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Test", 257, 182, 192, 124)
$test = GUICtrlCreateEdit("", 8, 40, 241, 90, $ES_AUTOVSCROLL)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ConsoleWriteGUI($test, 'Shutting down in 10 seconds ...' & @CRLF)
            Sleep(5 * 1000)
            ConsoleWriteGUI($test, '5 more seconds ...' & @CRLF)
            Sleep(5 * 1000)
            Exit
    EndSwitch
WEnd

Func ConsoleWriteGUI(Const ByRef $hConsole, Const $sTxt)
    Local Static $sContent = ''

    $sContent &= $sTxt
    GUICtrlSetData($hConsole, $sContent)

EndFunc


来源:https://stackoverflow.com/questions/47075748/consolewrite-to-guictrl-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!