本文介绍了ConsoleWrite()到GUICtrl元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将ConsoleWrite()放入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')

推荐答案

根据文档-函数参考-GUICtrlSetData() :

示例:

#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

示例:

#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

这篇关于ConsoleWrite()到GUICtrl元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 01:17