无法使用AutoIt v3.3.8.1创建多个Rich Edits

时间:2018-08-07 10:26:59

标签: windows autoit richedit richedit-control

我正在使用AutoIt v3.3.8.1来实现Win2K兼容性。我正在尝试创建一个包含多个Rich Edits的表单。相关代码部分如下:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <GuiEdit.au3>
#include <GuiRichEdit.au3>

; Enforces strict variable declaration rules
Opt("MustDeclareVars", 1)

; Initialise application
Init()

; Function declarations
Func Init()
  GenerateGUI()
  StartEventListener()
EndFunc

Func GenerateGUI()
  ; GUI designed via Koda FormDesigner tool
  #Region ### START Koda GUI section ### Form=
  Global $SAForm = GUICreate("", 800, 600)
  Global $SATabs = GUICtrlCreateTab(0, 0, 800, 600)

  Global $ConfigTab = GUICtrlCreateTabItem("Configuration Settings")

  Global $TestTab = GUICtrlCreateTabItem("Tests")
    Global $NetTestGrp = GUICtrlCreateGroup("Network Connectivity", 4, 25, 792, 134)
    Global $NetDestListLbl = GUICtrlCreateLabel("Destinations to Test:", 14, 51, 102, 18)
    Global $NetDestListEdit = GUICtrlCreateEdit("", 116, 48, 279, 66, _
        BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN))
    Global $NetPingResultLbl = GUICtrlCreateLabel("Ping Test Result:", 405, 51, 84, 18)
    ;Global $NetPingResultEdit = GUICtrlCreateEdit("", 489, 48, 297, 66, _
    ;    BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL))
    Global $NetPingResultEdit = _GUICtrlRichEdit_Create($SAForm, "", 489, 48, 297, 66, _
        BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_TABSTOP,$WS_VSCROLL), _
        BitOR($WS_EX_CLIENTEDGE,$WS_EX_TRANSPARENT))
    _GUICtrlRichEdit_SetReadOnly($NetPingResultEdit, True)
    Global $NetPingTestBtn = GUICtrlCreateButton("Start Ping Test", 350, 124, 100, 25)

    Global $ResUtilGrp = GUICtrlCreateGroup("Resource Utilisation", 4, 160, 792, 437)
    Global $ResDskUseLbl = GUICtrlCreateLabel("Disk Usage:", 14, 183, 61, 18)
    ;Global $ResDskUseEdit = GUICtrlCreateEdit("", 14, 201, 250, 110, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_VSCROLL))
    Global $ResDskUseEdit = _GUICtrlRichEdit_Create($SAForm, "", 14, 201, 250, 110, _
        BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_TABSTOP,$WS_VSCROLL), $WS_EX_CLIENTEDGE)
        ;BitOR($WS_EX_CLIENTEDGE,$WS_EX_TRANSPARENT))
    _GUICtrlRichEdit_SetReadOnly($ResDskUseEdit, True)
    Global $ResCpuUseLbl = GUICtrlCreateLabel("CPU Usage:", 275, 183, 61, 18)
    ;Global $ResCpuUseEdit = GUICtrlCreateEdit("", 275, 201, 250, 110, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_VSCROLL))
    Global $ResCpuUseEdit = _GUICtrlRichEdit_Create($SAForm, "", 275, 201, 250, 110, _
        BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_TABSTOP,$WS_VSCROLL), $WS_EX_CLIENTEDGE)
        ;BitOR($WS_EX_CLIENTEDGE,$WS_EX_TRANSPARENT))
    _GUICtrlRichEdit_SetReadOnly($ResCpuUseEdit, True)
    Global $ResMemUseLbl = GUICtrlCreateLabel("Memory Usage:", 536, 183, 79, 18)
    ;Global $ResMemUseEdit = GUICtrlCreateEdit("", 536, 201, 250, 110, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_VSCROLL))
    Global $ResMemUseEdit = _GUICtrlRichEdit_Create($SAForm, "", 536, 201, 250, 110, _
        BitOR($ES_MULTILINE,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$WS_TABSTOP,$WS_VSCROLL), $WS_EX_CLIENTEDGE)
        ;BitOR($WS_EX_CLIENTEDGE,$WS_EX_TRANSPARENT))
    _GUICtrlRichEdit_SetReadOnly($ResMemUseEdit, True)

    ;$RUUtilBtn = GUICtrlCreateButton("Check Usage", 350, 303, 100, 25)

  Global $TaskTab = GUICtrlCreateTabItem("Tasks")

  Global $LogTab = GUICtrlCreateTabItem("Log")
    Global $LogDisplay = GUICtrlCreateEdit("", 4, 25, 792, 531, _
        BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$WS_HSCROLL,$WS_VSCROLL))
    Global $ExportLogBtn = GUICtrlCreateButton("Export Log", 320, 566, 75, 25)
    Global $ClearLogBtn = GUICtrlCreateButton("Clear Log", 405, 566, 75, 25)

  GUISetState(@SW_SHOW)
  #EndRegion ### END Koda GUI section ###

  _GUICtrlTab_ClickTab($SATabs, _GUICtrlTab_FindTab($SATabs, "Tests"))
EndFunc

Func StartEventListener()
  While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE
        Exit

      Case $SATabs
        Local $currTab = GUICtrlRead($SATabs, 1)
        If $currTab <> $lastTab Then
          If $currTab = $TestTab Then
            ControlShow($SAForm, "", $NetPingResultEdit)
          Else
            ControlHide($SAForm, "", $NetPingResultEdit)
          EndIf
        EndIf
        $lastTab = $currTab

      Case $NetPingTestBtn
        RunPingTest()

      Case $ExportLogBtn
        ExportLog()

    EndSwitch
  WEnd
EndFunc

运行脚本时,只有第一个声明的丰富编辑可见。其余的似乎根本没有创建。这里有什么问题,我该如何解决?

1 个答案:

答案 0 :(得分:1)

  

这里是什么问题 ...”

它是a bug,已在AutoIt v3.3.9.0中修复。

  

“ ... ... 该如何纠正?

可以从最新版本中提取_GUICtrlRichEdit_Create()。宁可升级操作系统并使用最新的AutoIt版本(自Windows NT 5.0's extended support ended起已经8年了。)