Jump to content
Sign in to follow this  
Fractured

Error messages in red in Edit Box

Recommended Posts

Ok..so ive been reading about RichEdit and cannot figure out how to make it do what I wish or if it even can.

My script gets information from the gui, send it via serial connection to a unit being tested and then gets info from the unit and displays it in an edit box. I have some basic error messages that get sent to the edit box if the user fails to enter certain info like the com port or other switch information. I would like these error messages to be displayed in red. BUT, it seems that when ive tried to use rich edit it makes all the text in the edit box red. I cant seem to find the proper syntax to just make the error line red....

Error lines of relevance are in Case $b_Connect, $b_IDN, $b_Console.

just need someone to realign my aim on this!

 

 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=3
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INDEX# ================================================================================================
; Name ..........: 10086_Core.au3
; Version Date ..: 2018-08-21
; AutoIt Version : 3.3.14.5
; Author(s) .....: Charles Wright
; Dll(s) ........:
; Error handling :
; ========================================================================================================


#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "ExtMsgBox.au3"        ; REF - Melba23 - Autoit Forum Moderator - Extended Message Box
#include <CommInterface.au3>    ; https://www.autoitscript.com/wiki/CommAPI_Examples

#include <_10086Commands.au3>   ; REF IM-583
#include <_10086Test.au3>       ; REF ATP-977

Local $ClickConnect = 0         ; Connection Flag - No double connect or program crashes
Global $uInput, $hFile
$SoundFile = "C:\Windows\Media\Windows Ding.wav"    ; Load Ding.wav for alerts
FileInstall("Sound.wav", $SoundFile)                ; Install wav when compiled

#Region ### START Koda GUI section ### Form=z:\work\macro\autoit scripts\mine\10086\10086_core.kxf
$g_Core = GUICreate("10086 Core", 883, 600, 196, 120)
GUISetBkColor(0xA6CAF0)
; ## Connection Group ##
$Connection = GUICtrlCreateGroup("Connection", 16, 8, 169, 81, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("COMM Port", 24, 24, 72, 20)
$i_CommPort = GUICtrlCreateInput("", 24, 48, 73, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$b_Connect = GUICtrlCreateButton("Connect", 104, 48, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ## Connection Group End ##
; ## Commands Group ##
$Commands = GUICtrlCreateGroup("Commands", 8, 96, 257, 473, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$b_IDNQuery = GUICtrlCreateButton("*IDN?", 24, 144, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_IDN = GUICtrlCreateButton("IDN", 24, 176, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_IDNserno = GUICtrlCreateInput("", 72, 176, 49, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Serial Number")
$b_ConsoleQuery = GUICtrlCreateButton("CONSOLE?", 24, 208, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_Console = GUICtrlCreateButton("CONSOLE", 24, 240, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_ConsoleMode = GUICtrlCreateInput("", 104, 240, 33, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "0, 1, 2, Off, On")
$b_Reboot = GUICtrlCreateButton("REBOOT", 96, 120, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$b_TempQuery = GUICtrlCreateButton("TEMP?", 24, 272, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_TempQueryChan = GUICtrlCreateInput("", 104, 272, 33, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "0 - Internal, 1 - Attenuator")
$b_HPLockQuery = GUICtrlCreateButton("HPLOCK?", 24, 304, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_HPLockQueryName = GUICtrlCreateInput("", 104, 304, 33, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Switch Id")
$b_ADCQuery = GUICtrlCreateButton("ADC?", 152, 240, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_ADCQueryChan = GUICtrlCreateInput("", 200, 240, 41, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Channel Number")
$b_ADCHelp = GUICtrlCreateButton("?", 240, 240, 19, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$b_LLOQuery = GUICtrlCreateButton("LLO?", 152, 272, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_LLO = GUICtrlCreateButton("LLO", 152, 304, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_LLO = GUICtrlCreateInput("", 200, 304, 41, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "0, 1, Off, On")
$b_Switch = GUICtrlCreateButton("SWITCH", 24, 352, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_SwNmStName = GUICtrlCreateInput("", 104, 352, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Switch Name")
$i_SwNmStSetting = GUICtrlCreateInput("", 184, 352, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Setting")
$b_SwitchQuery = GUICtrlCreateButton("SWITCH?", 24, 384, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_Help2 = GUICtrlCreateButton("?", 184, 384, 19, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$i_SwitchNameQuery = GUICtrlCreateInput("", 104, 384, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Switch Name")
$b_Help1 = GUICtrlCreateButton("?", 240, 352, 19, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$b_SetTempSenseLimit = GUICtrlCreateButton("SET TEMPSENSE LIMIT", 24, 432, 139, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_SetTempSenseLimit = GUICtrlCreateInput("", 168, 432, 81, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Temp in degC")
$b_SetSerialBaudRate = GUICtrlCreateButton("SET SERIAL BAUDRATE", 24, 464, 139, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_SetSerialBaudRate = GUICtrlCreateCombo("115200", 168, 464, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "9600|19200|38400|57600|115200|230400")
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_CLS = GUICtrlCreateButton("*CLS", 16, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_OPC = GUICtrlCreateButton("*OPC?", 64, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_RST = GUICtrlCreateButton("*RST", 112, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_TST = GUICtrlCreateButton("*TST?", 160, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_ERR = GUICtrlCreateButton("ERR?", 208, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_ShowSet = GUICtrlCreateButton("SHOW SET", 176, 176, 75, 25)
$b_TempSensorQuery = GUICtrlCreateButton("TEMPSENSOR?", 168, 208, 91, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ## Commands Group End ##
; ## Test Group ##
$Group1 = GUICtrlCreateGroup("Test", 272, 96, 185, 489, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$b_SWHF11 = GUICtrlCreateButton("SW HF1 1", 288, 120, 75, 25)
$b_SWHF12 = GUICtrlCreateButton("SW HF1 2", 368, 120, 75, 25)
$b_SWVUHF11 = GUICtrlCreateButton("SW VUHF1 1", 288, 168, 75, 25)
$b_SWVUHF21 = GUICtrlCreateButton("SW VUHF2 1", 288, 200, 75, 25)
$b_SWVUHF31 = GUICtrlCreateButton("SW VUHF3 1", 288, 232, 75, 25)
$b_SWVUHF12 = GUICtrlCreateButton("SW VUHF1 2", 368, 168, 75, 25)
$b_SWVUHF22 = GUICtrlCreateButton("SW VUHF2 2", 368, 200, 75, 25)
$b_SWVUHF32 = GUICtrlCreateButton("SW VUHF3 2", 368, 232, 75, 25)
$b_SWVUHFACQ1 = GUICtrlCreateButton("SW VUHFACQ 1", 296, 272, 139, 25)
$b_SWVUHFACQ2 = GUICtrlCreateButton("SW VUHFACQ 2", 296, 304, 139, 25)
$b_SWVUHFACQ3 = GUICtrlCreateButton("SW VUHFACQ 3", 296, 336, 139, 25)
$b_SWVUHFACQ4 = GUICtrlCreateButton("SW VUHFACQ 4", 296, 368, 139, 25)
$b_SWIO11 = GUICtrlCreateButton("SW IO1 1", 288, 408, 75, 25)
$b_SWIO21 = GUICtrlCreateButton("SW IO2 1", 288, 440, 75, 25)
$b_SWIO31 = GUICtrlCreateButton("SW IO3 1", 288, 472, 75, 25)
$b_SWIO12 = GUICtrlCreateButton("SW IO1 2", 368, 408, 75, 25)
$b_SWIO22 = GUICtrlCreateButton("SW IO2 2", 368, 440, 75, 25)
$b_SWIO32 = GUICtrlCreateButton("SW IO3 2", 368, 472, 75, 25)
$b_ShowStat = GUICtrlCreateButton("SHOW STAT", 288, 512, 155, 25)
$b_SetTempSenseLimit60 = GUICtrlCreateButton("SET TEMPSENSE LIMIT 60", 288, 544, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ## Test Group Ends ##
$Edit1 = GUICtrlCreateEdit("", 472, 16, 393, 529, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
GUICtrlSetData(-1, "")
$b_OutFile = GUICtrlCreateButton("Output to File", 616, 552, 75, 25)
$i_Manual = GUICtrlCreateInput("", 200, 16, 265, 21)
$b_SendManual = GUICtrlCreateButton("Manual Send", 296, 40, 75, 25)
Global $aAccelKeys[1][2] = [["{ENTER}", $b_SendManual]]
GUISetAccelerators($aAccelKeys)

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

Local $sCommPorts = _CommAPI_GetCOMPorts()  ; ref https://www.autoitscript.com/wiki/CommAPI_Examples
Local $uCommPorts = "COM Ports:" & @LF & $sCommPorts & @LF
_GUICtrlEdit_AppendText($Edit1, "---------------------------------------" & @CRLF)
_GUICtrlEdit_AppendText($Edit1, $uCommPorts)
_GUICtrlEdit_AppendText($Edit1, "---------------------------------------" & @CRLF)

While 1
    $msg = GUIGetMsg()
    Switch $msg

        Case $GUI_EVENT_CLOSE
            Exit

        Case $b_Connect
            If $ClickConnect = 0 then
                _Connect()
            Else
                SoundPlay($SoundFile)   ; Error Alert
                _GUICtrlEdit_AppendText($Edit1, "You are already Connected." & @CRLF & @LF)
                GUICtrlSetState($b_SendManual, $GUI_FOCUS)
            Endif

        Case $b_IDNQuery
            _IDNQuery()
            _uSend($uInput)

        Case $b_IDN
            Global $Error_IDNserno = GUICtrlRead($i_IDNserno)
            If Not $Error_IDNserno = "" Then
                _IDNAssign()
                _uSend($uInput)
                $Error_IDNserno = ""
            Else
                SoundPlay($SoundFile)   ; Error Alert
                _GUICtrlEdit_AppendText($Edit1, "Please enter the Models Serial Number." & @CRLF & @LF)
            Endif

        Case $b_ConsoleQuery
            _ConsoleQuery()
            _uSend($uInput)

        Case $b_Console
            Global $Error_ConsoleMode = GUICtrlRead($i_ConsoleMode)
            If Not $Error_ConsoleMode = "" Then
                _ConsoleMode()
                _uSend($uInput)
                $Error_ConsoleMode = ""
            Else
                SoundPlay($SoundFile)   ; Error Alert
                _GUICtrlEdit_AppendText($Edit1, "Please enter Mode# 0, 1, 2." & @CRLF & @LF)
            Endif

        Case $b_ShowStat
            _ShowStat()
            _uSend($uInput)

        Case $b_Reboot
            _Reboot()
            _uSend($uInput)

        Case $b_TempQuery
            _TempQuery()
            _uSend($uInput)

        Case $b_HPLockQuery
            _HPLockQuery()
            _uSend($uInput)

        Case $b_ADCQuery
            _ADCQuery()
            _uSend($uInput)

        Case $b_LLOQuery
            _LLOQuery()
            _uSend($uInput)

        Case $b_LLO
            _LLO()
            _uSend($uInput)

        Case $b_Switch
            _SwitchNameSetting()
            _uSend($uInput)

        Case $b_SwitchQuery
            _SwitchNameQuery()
            _uSend($uInput)

        Case $b_SetTempSenseLimit
            _SetTempSenseLimit()
            _uSend($uInput)

        Case $b_SetSerialBaudRate
            _SetSerialBaudRate()
            _uSend($uInput)

        Case $b_CLS
            _CLS()
            _uSend($uInput)

        Case $b_OPC
            _OpCompleteQuery()
            _uSend($uInput)

        Case $b_RST
            _Reset()
            _uSend($uInput)

        Case $b_TST
            _SelfTest()
            _uSend($uInput)

        Case $b_ERR
            _ERRQuery()
            _uSend($uInput)

        Case $b_ShowSet
            _ShowSet()
            _uSend($uInput)

        Case $b_TempSensorQuery
            _TempSensorQuery()
            _uSend($uInput)

        Case $b_Help1
            _Help1()

        Case $b_Help2
            _Help1()

        Case $b_ADCHelp
            _ADCHelp()

; ## Test ##
; ## Test ##
        Case $b_SWHF11
            _SWHF11()
            _uSend($uInput)

        Case $b_SWHF12
            _SWHF12()
            _uSend($uInput)

        Case $b_SWVUHF11
            _SWVUHF11()
            _uSend($uInput)

        Case $b_SWVUHF21
            _SWVUHF21()
            _uSend($uInput)

        Case $b_SWVUHF31
            _SWVUHF31()
            _uSend($uInput)

        Case $b_SWVUHF12
            _SWVUHF12()
            _uSend($uInput)

        Case $b_SWVUHF22
            _SWVUHF22()
            _uSend($uInput)

        Case $b_SWVUHF32
            _SWVUHF32()
            _uSend($uInput)

        Case $b_SWVUHFACQ1
            _SWVUHFACQ1()
            _uSend($uInput)

        Case $b_SWVUHFACQ2
            _SWVUHFACQ2()
            _uSend($uInput)

        Case $b_SWVUHFACQ3
            _SWVUHFACQ3()
            _uSend($uInput)

        Case $b_SWVUHFACQ4
            _SWVUHFACQ4()
            _uSend($uInput)

        Case $b_SWIO11
            _SWIO11()
            _uSend($uInput)

        Case $b_SWIO21
            _SWIO21()
            _uSend($uInput)

        Case $b_SWIO31
            _SWIO31()
            _uSend($uInput)

        Case $b_SWIO12
            _SWIO12()
            _uSend($uInput)

        Case $b_SWIO22
            _SWIO22()
            _uSend($uInput)

        Case $b_SWIO32
            _SWIO32()
            _uSend($uInput)

        Case $b_ShowSet
            _ShowSet()
            _uSend($uInput)

        Case $b_SetTempSenseLimit60
            _SetTempSense()
            _uSend($uInput)

        Case $b_SendManual
            _ManualSend()

        Case $b_OutFile
            _OutFile()
    EndSwitch
WEnd
; ### Internal Functions ##################################################################################

; #FUNCTION# ==============================================================================================
; Name ..........: Main
; =========================================================================================================
Func _Main()
    Local $sResult = _Connect()

    Switch @error
        Case 0
            GUICtrlSetColor($b_Connect, 0x33FF00)
        Case -1
            MsgBox(32, "Error", _WinAPI_GetLastErrorMessage())
        Case -2
            MsgBox(32, "Timeout", $sResult)
        Case Else
            MsgBox(32, "Error", "Error " & @error & " in line " & @extended)
    EndSwitch
EndFunc   ;==>_Main

; #FUNCTION# ==============================================================================================
; Name ..........: Connect
; =========================================================================================================
Func _Connect()

    Global $uPort = GUICtrlRead($i_CommPort)

    If $uPort = "" Then
        SoundPlay($SoundFile)   ; Error Alert
        _GUICtrlEdit_AppendText($Edit1, @CRLF & @LF)
        _GUICtrlEdit_AppendText($Edit1, "Please Enter a Model Number." & @CRLF & @LF)
        $ClickConnect = 0   ; Connection Flag - no connection
        GUICtrlSetState($i_Manual, $GUI_FOCUS)
        Return
    EndIf

    Local Const $iPort = "" & $uPort & ""
    Local Const $iBaud = "115000"
    Local Const $iParity = "0"
    Local Const $iByteSize = "8"
    Local Const $iStopBits = "1"

    GUICtrlSetState($i_Manual, $GUI_FOCUS)
    $ClickConnect = 1   ; Connection Flag - connection established

    Global $hFile = _CommAPI_OpenCOMPort($iPort, $iBaud, $iParity, $iByteSize, $iStopBits) ; Ref commAPI

    _GUICtrlEdit_AppendText($Edit1, "Connected to CommPot: " & $uPort& @CRLF & @LF)
    _GUICtrlEdit_AppendText($Edit1, "---------------------------------------" & @CRLF)
EndFunc   ;==>_Connect

; #FUNCTION# ==============================================================================================
; Name ..........: _uSend
; =========================================================================================================
Func _uSend($uInput)

    If @error Then Return SetError(@error, @ScriptLineNumber)

    _CommAPI_ClearCommError($hFile)
    If @error Then Return SetError(@error, @ScriptLineNumber)

    _CommAPI_PurgeComm($hFile)
    If @error Then Return SetError(@error, @ScriptLineNumber)

    _CommAPI_TransmitString($hFile, $uInput & @CR)                          ; _CommAPI_TransmitData(Const $hFile, Const $sData)
    If @error Then Return SetError(@error, @ScriptLineNumber)
    GUICtrlSetData($uInput, "")

    Local $sResult = _CommAPI_ReceiveString($hFile, 1000)                   ;_CommAPI_ReceiveString(Const $hFile[, $iTimeout = 1[, $iMaxLength = 0[, $sSeparator = ""]]])
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

    Sleep(500)

    _GUICtrlEdit_AppendText($Edit1, $sResult & @CRLF)
    _GUICtrlEdit_AppendText($Edit1, "---------------------------------------" & @CRLF)

    Return $sResult

EndFunc   ;==>_uSend

; #FUNCTION# ==============================================================================================
; Name ..........: _ManualSend
; =========================================================================================================
Func _ManualSend()

    If $hFile = "" Then
        SoundPlay($SoundFile)   ; Error Alert
        _GUICtrlEdit_AppendText($Edit1, @CRLF & @LF)
        _GUICtrlEdit_AppendText($Edit1, "Incorrect or Incomplete Command" & @CRLF & @LF) 
        Return
    EndIf

    _CommAPI_TransmitString($hFile, GUICtrlRead($i_Manual) & @CR)           ; _CommAPI_TransmitData(Const $hFile, Const $sData)
    If @error Then Return SetError(@error, @ScriptLineNumber)
    GUICtrlSetData($i_Manual, "")

    Local $sResult = _CommAPI_ReceiveString($hFile, 1000)   ;_CommAPI_ReceiveString(Const $hFile[, $iTimeout = 1[, $iMaxLength = 0[, $sSeparator = ""]]])
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

    _GUICtrlEdit_AppendText($Edit1, $sResult & @CRLF & @LF)
    _GUICtrlEdit_AppendText($Edit1, "---------------------------------------" & @CRLF)

    GUICtrlSetState($i_Manual, $GUI_FOCUS)

    Return $sResult

EndFunc   ;==>_ManualSend

; #FUNCTION# ==============================================================================================
; Name ..........: _Help1
; =========================================================================================================
Func _Help1()
            ; Hide the main GUI to centre the message box on screen
            GUISetState(@SW_HIDE, $g_Core)

            ; Change font and justification, leaving colours unchanged
            _ExtMsgBoxSet(1 + 4, $SS_LEFT, -1, -1, 12, "Arial")

            $sMsg = "Valid switch identifiers include:" & @CRLF & @CRLF
            $sMsg &= "HF1 / HF2 1-2" & @CRLF
            $sMsg &= "VUHFACQ 1-4" & @CRLF
            $sMsg &= "VUHF1 1-2" & @CRLF
            $sMsg &= "VUHF2 1-2" & @CRLF
            $sMsg &= "VUHF3 1-2" & @CRLF
            $sMsg &= "IO1 1-2" & @CRLF
            $sMsg &= "IO2 1-2" & @CRLF
            $sMsg &= "IO3 1-2" & @CRLF & @CRLF

            ; Use $MB_ constants and set timeout value
            $iRetValue = _ExtMsgBox($EMB_ICONINFO, "Close", "Switch Help", $sMsg, 5, $g_Core)
            ;ConsoleWrite("Test 2 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

            ; Show the main GUI again
            GUISetState(@SW_SHOW, $g_Core)
            WinSetOnTop($g_Core, "", 1)
            WinSetOnTop($g_Core, "", 0)
EndFunc

; #FUNCTION# ==============================================================================================
; Name ..........: _ADCHelp
; =========================================================================================================
Func _ADCHelp()
            ; Hide the main GUI to centre the message box on screen
            GUISetState(@SW_HIDE, $g_Core)

            ; Change font and justification, leaving colours unchanged
            _ExtMsgBoxSet(1 + 4, $SS_LEFT, -1, -1, 12, "Arial")

            $sMsg = "Valid ADC? Channels:" & @CRLF & @CRLF
            $sMsg &= "0 – Internal Temp Sensor" & @CRLF
            $sMsg &= "6 – Power Sensor #1" & @CRLF
            $sMsg &= "7 – Power Sensor #2" & @CRLF
            $sMsg &= "8 – Power Sensor #3" & @CRLF
            $sMsg &= "10 – Attenuator Heatsink Temp Sensor" & @CRLF

            ; Use $MB_ constants and set timeout value
            $iRetValue = _ExtMsgBox($EMB_ICONINFO, "Close", "ADC? Help", $sMsg, 5, $g_Core)
            ;ConsoleWrite("Test 2 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

            ; Show the main GUI again
            GUISetState(@SW_SHOW, $g_Core)
            WinSetOnTop($g_Core, "", 1)
            WinSetOnTop($g_Core, "", 0)
EndFunc


; #FUNCTION# ==============================================================================================
; Name ..........: _OutFile   REF: Bowmore - Autoit Forum User - CtrlSetText - Output Editbox to Notepad
; =========================================================================================================
Func _OutFile()

    $TempEdit = GUICtrlRead($Edit1)
    $OutEdit = $TempEdit

    Run("notepad.exe")

    WinWaitActive("Untitled - Notepad")
    Sleep(1000)
    ControlSetText("Untitled - Notepad", "", "Edit1", $OutEdit)
EndFunc

 

Share this post


Link to post
Share on other sites

Ty..missed that doc...but it seems my brains not functioning at this moment....so afew quick questions to clear up my grey matter....

1. Do I need to use the _GUICtrlRichEdit_Create function to make my edit box?

2.  Would I have to append the text as I do now, then use _GUICtrlRichEdit_SetSel and _SetCharColor after? 

I have tried this:

If $uPort = "" Then
        SoundPlay($SoundFile)   ; Error Alert
        $ErrorMsg = "Please Enter a Model Number." & @CRLF & @LF
        _GUICtrlEdit_AppendText($Edit1, $ErrorMsg)
        _GUICtrlRichEdit_SetSel($Edit1, 0, -1)
        _GUICtrlRichEdit_SetCharColor($Edit1, $COLOR_RED)
        $ClickConnect = 0   ; Connection Flag - no connection
        GUICtrlSetState($i_Manual, $GUI_FOCUS)
        Return
    EndIf
And  a few different combos of this, but none seem to work..never used these functions before so abit confused. Ty in advance!

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...