Jump to content

Recommended Posts

Posted (edited)

sorry for the crappy code but when I press F5 and do ctrl-a and start typing, the font is black and default again...

Selecting all text in code and setting character attributes helps but this is not the right way I think, especially when opening and closing files.

#include <GuiRichEdit.au3>
;#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Tom Schrauwen\Desktop\EDIT.kxf
$Form1 = GUICreate("Form1", 301, 221, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem9 = GUICtrlCreateMenuItem("Open", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("Save", $MenuItem1)
$MenuItem7 = GUICtrlCreateMenuItem("Save As", $MenuItem1)
$MenuItem8 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("Edit")
$MenuItem15 = GUICtrlCreateMenuItem("Uppercase", $MenuItem2)
$MenuItem14 = GUICtrlCreateMenuItem("Lowercase", $MenuItem2)
$MenuItem13 = GUICtrlCreateMenuItem("Mark Red", $MenuItem2)
$MenuItem12 = GUICtrlCreateMenuItem("Mark Green", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("Mark Blue", $MenuItem2)
$MenuItem10 = GUICtrlCreateMenuItem("Unmark", $MenuItem2)
$MenuItem17 = GUICtrlCreateMenuItem("Search And Replace", $MenuItem2)
$MenuItem16 = GUICtrlCreateMenu("Settings")
$MenuItem19 = GUICtrlCreateMenuItem("Font", $MenuItem16)
$MenuItem18 = GUICtrlCreateMenuItem("Background", $MenuItem16)
$MenuItem3 = GUICtrlCreateMenu("Info")
$MenuItem5 = GUICtrlCreateMenuItem("Help", $MenuItem3)
$MenuItem20 = GUICtrlCreateMenuItem("Document", $MenuItem3)
$MenuItem4 = GUICtrlCreateMenuItem("About", $MenuItem3)


$Edit1 = _GUICtrlRichEdit_Create($Form1, "", 10, 10, 300, 220, -1, 0)
;_GUICtrlRichEdit_SetSel($Edit1, 0, -1) ; temporary fix but not the best solution
_GUICtrlRichEdit_SetBkColor($Edit1, 0x000000)
_GUICtrlRichEdit_SetCharColor($Edit1, 0xFFFFFF)
_GUICtrlRichEdit_SetFont($Edit1, 12, 'Lucida Console')


GUICtrlSetData(-1, "Edit1")
GUICtrlSetFont(-1, 10, 400, 0, "Consolas")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x444444)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($Edit1) ; needed unless script crashes
            Exit
        case $MenuItem13
            _GUICtrlRichEdit_SetCharColor($Edit1, 0x0000FF)
        case $MenuItem12
            _GUICtrlRichEdit_SetCharColor($Edit1, 0x00FF00)
        case $MenuItem11
            _GUICtrlRichEdit_SetCharColor($Edit1, 0xFF0000)
        case $MenuItem19
            _GUICtrlRichEdit_SetCharAttributes($Edit1, "+bo")
        case $MenuItem6
            _GUICtrlRichEdit_StreamToFile($Edit1, @ScriptDir & "\RichEdit.rtf")
        case $MenuItem9
            _GUICtrlRichEdit_StreamFromFile($Edit1, @ScriptDir & "\RichEdit.rtf")

    EndSwitch
WEnd
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

As always, thanks for any help!
TheAutomator

Edited by TheAutomator
code was not clear
Posted (edited)
On 11/13/2024 at 12:44 AM, ioa747 said:

me with AutoIt Version..: 3.3.16.1
I could not reproduce your problem

Becouse i left the temporary solution in (edit: commented outthat part)
not good for all cases, especially when loading new files into the edit: 

_GUICtrlRichEdit_SetSel($Edit1, 0, -1) ; temporary fix but not the best solution
Edited by TheAutomator

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
×
×
  • Create New...