Jump to content

Blank ComboBox while listing fonts


Go to solution Solved by Nine,

Recommended Posts

Hello,

i would like to know why isnt anything displayed on the combo box. i used this example and added it to my code

Autoit Example :

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"

GUICreate("Test", 400, 100)

$cCombo_Font = GUICtrlCreateCombo("", 10, 10, 170, 20, 2097474);HELPHERE
GUICtrlSetData($cCombo_Font, _RegEnumVal($sRegKey))

$cLabel = GUICtrlCreateLabel("Font preview", 230, 10, 155, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cCombo_Font
            GUICtrlSetFont($cLabel, 10, Default, Default, GUICtrlRead($cCombo_Font))
    EndSwitch
WEnd

Func _RegEnumVal($sKey)
    Local $i = 1, $sVal, $sResult

    While 1
        $sVal = RegEnumVal($sKey, $i)
        If @error Then ExitLoop
        $i += 1
        $sResult &= $sVal & "|"
    WEnd

    Return StringRegExpReplace($sResult, " \(.*?\)", "")
EndFunc   ;==>_RegEnumVal

And my code:

#NoTrayIcon

#include <Misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiEdit.au3>
#include <String.au3>
#include <GuiRichEdit.au3>
#include <GuiToolbar.au3>
#include <GuiImageList.au3>

$WIDTH = 500
$HEIGHT = 380
$EXT1 = "|Rich Text File (*.rtf)"
$EXT2 = "|ODF Text (*.odt)"
$EXT3 = "|All Files(*.*)"
$EXT = $EXT1 & $EXT2
$SETTINGS = "Settings.ini"
Dim $FONTKEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
Global $FILESAVE, $FILEOPEN = "", $SAVES, $SAVE, $FILEOPENED = 0
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp


$MAINGUI = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)

 $TOOLBAR = _GUICtrlToolbar_Create($MAINGUI)
 _GUIImageList_AddIcon($TOOLBAR, @SystemDir & "\shell.dll", -1)
 $IMAGES = _GUIImageList_Create(24,24)
 _GUICtrlToolbar_SetImageList($TOOLBAR, $IMAGES)



 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -1);AndHereIfYouCouldTHX
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -2)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 3)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 4)
 _GUICtrlToolbar_AddButtonSep($TOOLBAR)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 5)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 6)


 $EDITBOX = _GUICtrlRichEdit_Create($MAINGUI, "This is a test.", 10, 35, $WIDTH - 20, $HEIGHT - 70, _
                  BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
$FONTCOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, 2097474);HELPMEHERE
GUICtrlSetData($FONTCOMBOBOX, _RegEnumVal($FONTKEY));ALSOHERE
$FONTSIZECOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, 2097474);FuncForPreviousLineAtTheEnd
$FILE = GUICtrlCreateMenu("File")

$NEW = GUICtrlCreateMenuItem("New", $FILE)
$OPEN = GUICtrlCreateMenuItem("Open...", $FILE)
$SAVE = GUICtrlCreateMenuItem("Save", $FILE)
$SAVEAS = GUICtrlCreateMenuItem("Save As...", $FILE)
$PRINT = GUICtrlCreateMenuItem("Print...", $FILE)

GUICtrlCreateMenuItem("", $FILE)

$EXIT = GUICtrlCreateMenuItem("Exit", $FILE)

$EDIT = GUICtrlCreateMenu("Edit")
$UNDO = GUICtrlCreateMenuItem("Undo", $EDIT)
$REDO = GUICtrlCreateMenuItem("Redo", $EDIT)
$SEPARATOR = GUICtrlCreateMenuItem("", $EDIT)
$FONT = GUICtrlCreateMenuItem("Font test", $EDIT)
$SEPARATOR1 = GUICtrlCreateMenuItem("", $EDIT)
$CUT = GUICtrlCreateMenuItem("Cut", $EDIT)
$COPY = GUICtrlCreateMenuItem("Copy", $EDIT)
$PASTE = GUICtrlCreateMenuItem("Paste", $EDIT)





GUISetState(@SW_SHOW & $GUI_ACCEPTFILES)


While 1
    $Msg = GUIGetMsg()
    Select

        Case $Msg = $GUI_EVENT_CLOSE
            If _GUICtrlEdit_CanUndo($EDITBOX) Then
                $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?")
                If $SAVECHANGES = 6 And $FILEOPENED = 0 Then
                    SaveAs()
                    _GUICtrlRichEdit_Destroy($hRichEdit)
                    Exit
                EndIf
                If $SAVECHANGES = 6 And $FILEOPENED = 1 Then
                    FileDelete($FILEOPEN)
                    FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
                    Exit
                EndIf
                If $SAVECHANGES = 7 Then
                    ExitLoop
                    Exit
                EndIf
            EndIf
            If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit

        Case $Msg = $OPEN
            $FILEOPEN = FileOpenDialog("Open", $FILEOPEN, $EXT)
            $TEXT = _GUICtrlRichEdit_StreamFromFile($EDITBOX, $FILEOPEN)
            _GUICtrlRichEdit_ReplaceText($EDITBOX, $TEXT)
            $FILEOPENED = 1

        Case $Msg = $NEW
            If _GUICtrlEdit_CanUndo($EDITBOX) Then
                $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?")
                If $SAVECHANGES = 6 And $FILEOPENED = 0 Then
                    SaveAs()
                EndIf
                If $SAVECHANGES = 6 And $FILEOPENED = 1 Then
                    FileDelete($FILEOPEN)
                    FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
                EndIf
                If $SAVECHANGES = 7 Then GUICtrlSetData($EDITBOX, "")
                If $SAVECHANGES = 2 Then Sleep(1)
            EndIf
            If Not _GUICtrlEdit_CanUndo($EDITBOX) Then GUICtrlSetData($EDITBOX, "")
            $FILEOPENED = 0

        Case $Msg = $EXIT
            If _GUICtrlEdit_CanUndo($EDITBOX) Then
                $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?")
                If $SAVECHANGES = 6 And $FILEOPENED = 0 Then
                    SaveAs()
                    _GUICtrlRichEdit_Destroy($hRichEdit)
                    Exit
                EndIf
                If $SAVECHANGES = 6 And $FILEOPENED = 1 Then
                    FileDelete($FILEOPEN)
                    FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
                    Exit
                EndIf
                If $SAVECHANGES = 7 Then ExitLoop
                If $SAVECHANGES = 2 Then
                    Sleep(1)
                EndIf
            EndIf
            If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit

        Case $Msg = $SAVEAS
            GUICtrlSetState($EDITBOX, $GUI_DISABLE)
            SaveAs()
            $FILEOPENED = 1
            GUICtrlSetState($EDITBOX, $GUI_ENABLE)

        Case $Msg = $SAVE And $FILEOPENED = 1
            FileDelete($FILEOPEN)
            FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
            _GUICtrlEdit_EmptyUndoBuffer($EDITBOX)

        Case $Msg = $SAVE And $FILEOPENED = 0
            GUICtrlSetState($EDITBOX, $GUI_DISABLE)
            SaveAs()
            $FILEOPENED = 1
            GUICtrlSetState($EDITBOX, $GUI_ENABLE)

        Case $Msg = $SAVE And $FILEOPENED = 0
            GUICtrlSetState($EDITBOX, $GUI_DISABLE)
            SaveAs()
            $FILEOPENED = 1
            GUICtrlSetState($EDITBOX, $GUI_ENABLE)

        Case $Msg = $PRINT
            $PRINTMSGBOX = MsgBox(35, "Text Editor", "Are you sure you want to print this page?")
            Select

                Case $PRINTMSGBOX = 6
                    If FileExists("Print.txt") Then
                        FileDelete("Print.txt")
                    EndIf
                    FileWrite("Print.txt", GUICtrlRead($EDITBOX))
                    $PRINTFILE = "Print.txt"
                    _FilePrint($PRINTFILE)
                    FileDelete($PRINTFILE)
            EndSelect

        Case $Msg = $UNDO
            _GUICtrlRichEdit_Undo($EDITBOX)

        Case $Msg = $REDO
            _GUICtrlRichEdit_Redo($EDITBOX)

        Case _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 1
            GUICtrlSetState($SAVE, $GUI_ENABLE)

        Case $Msg = $CUT
            _GUICtrlRichEdit_Cut ($EDITBOX)

        Case $Msg = $COPY
            _GUICtrlRichEdit_Copy ($EDITBOX)

        Case $Msg = $PASTE
            _GUICtrlRichEdit_Paste ($EDITBOX)

        Case Not _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 0
            GUICtrlSetState($SAVE, $GUI_DISABLE)
            $SAVES = 1
         Case $Msg = $FONT
            _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, "Times New Roman")

         Case $FONTCOMBOBOX
            _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, GUICtrlRead($FONTCOMBOBOX))
    EndSelect
WEnd
Exit

Func SaveAs()
    $FILESAVEAS = FileSaveDialog("Save As", "", "Text Document (*.txt)|All Files (*.*)")
    If Not @error Then
        $STRING = StringSplit($FILESAVEAS, ".")
        If $STRING[0] = 1 Then
            FileDelete($FILESAVEAS)
            _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf")
        Else
            _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf")
        EndIf
    EndIf
 EndFunc


Func _RegEnumVal($sKey)
    Local $i = 1, $sVal, $sResult

    While 1
        $sVal = RegEnumVal($sKey, $i)
        If @error Then ExitLoop
        $i += 1
        $sResult &= $sVal & "|"
    WEnd

    Return StringRegExpReplace($sResult, " \(.*?\)", "")
 EndFunc   ;==>_RegEnumVal

So the problem is that

  1. The second combo box is blank
  2. Icons in taskbar are not appearing (don't really care for now, .dll file for icon in attachement)
  3. problem with
    $FONTCOMBOBOX = GUICtrlCreateCombo("", 10, 10, 200, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL)

    (BitOR gave me a weird error)

Thanks !

Autoit newbie

ico.dll

Link to comment
Share on other sites

ComboBox is below the toolbar, either position it lower or place the GuiCtrlCreateCombo above the toolbar for example:

#include <ComboConstants.au3>

Global $g_hMainGui = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)
Global $g_idFontNames = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL))
    GUICtrlSetData($g_idFontNames, _RegEnumVal($FONTKEY));ALSOHERE
Global $g_idFontSizes = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL))

Global $g_hToolBar = _GUICtrlToolbar_Create($g_hMainGui)
...

 

Link to comment
Share on other sites

7 hours ago, Subz said:

ComboBox is below the toolbar, either position it lower or place the GuiCtrlCreateCombo above the toolbar for example:

#include <ComboConstants.au3>

Global $g_hMainGui = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)
Global $g_idFontNames = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL))
    GUICtrlSetData($g_idFontNames, _RegEnumVal($FONTKEY));ALSOHERE
Global $g_idFontSizes = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, Bitor($CBS_SORT,$CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_VSCROLL))

Global $g_hToolBar = _GUICtrlToolbar_Create($g_hMainGui)
...

 

For the combobox it worked but the BitOR also gave me an error

image.png.61841227a0db33f73a0ee55365bf1959.png

Also when  i tried to set the font using

_GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, GUICtrlRead($FONTCOMBOBOX))

it dosen't work because when i click on the combo box it deselect the text that i selected on my editbox.

again Thanks so much for your support

Link to comment
Share on other sites

5 hours ago, AFrenchCroissant said:

BitOR also gave me an error

use #include <GuiConstants.au3> instead of #include <GuiConstantsEx.au3>

6 hours ago, AFrenchCroissant said:

it dosen't work because when i click on the combo box it deselect the text

Use style $ES_NOHIDESEL in rich edit creation.

Link to comment
Share on other sites

Link to comment
Share on other sites

sorry i don't really understand what's wrong, i searched for errors in the script but couldn't find some

The only thing i noticed was that when you click anything on the toolbar or on the menus everything flickers

here is the code:

#NoTrayIcon

#include <Misc.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiEdit.au3>
#include <String.au3>
#include <GuiRichEdit.au3>
#include <GuiToolbar.au3>
#include <GuiImageList.au3>

$WIDTH = 500
$HEIGHT = 380
$EXT1 = "|Rich Text File (*.rtf)"
$EXT2 = "|ODF Text (*.odt)"
$EXT3 = "|All Files(*.*)"
$EXT = $EXT1 & $EXT2
$SETTINGS = "Settings.ini"
Dim $FONTKEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
Global $FILESAVE, $FILEOPEN = "", $SAVES, $SAVE, $FILEOPENED = 0
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp
$FONTSIZECOMBOBOX = 18


$MAINGUI = GUICreate("Text Editor", $WIDTH, $HEIGHT, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)



 $EDITBOX = _GUICtrlRichEdit_Create($MAINGUI, "This is a test.", 10, 35, $WIDTH - 20, $HEIGHT - 70, _
                  BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_NOHIDESEL))
$FONTCOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 170, 10, 160, 20, 2097474);HELPMEHERE
GUICtrlSetData($FONTCOMBOBOX, _RegEnumVal($FONTKEY));ALSOHERE
$FONTSIZECOMBOBOX = GUICtrlCreateCombo("", $WIDTH - 200, 10, 20, 20, 2097474);FuncForPreviousLineAtTheEnd
$FILE = GUICtrlCreateMenu("File")

$NEW = GUICtrlCreateMenuItem("New", $FILE)
$OPEN = GUICtrlCreateMenuItem("Open...", $FILE)
$SAVE = GUICtrlCreateMenuItem("Save", $FILE)
$SAVEAS = GUICtrlCreateMenuItem("Save As...", $FILE)
$PRINT = GUICtrlCreateMenuItem("Print...", $FILE)

GUICtrlCreateMenuItem("", $FILE)

$EXIT = GUICtrlCreateMenuItem("Exit", $FILE)

$EDIT = GUICtrlCreateMenu("Edit")
$UNDO = GUICtrlCreateMenuItem("Undo", $EDIT)
$REDO = GUICtrlCreateMenuItem("Redo", $EDIT)
$SEPARATOR = GUICtrlCreateMenuItem("", $EDIT)
$FONT = GUICtrlCreateMenuItem("Font test", $EDIT)
$SEPARATOR1 = GUICtrlCreateMenuItem("", $EDIT)
$CUT = GUICtrlCreateMenuItem("Cut", $EDIT)
$COPY = GUICtrlCreateMenuItem("Copy", $EDIT)
$PASTE = GUICtrlCreateMenuItem("Paste", $EDIT)

 $TOOLBAR = _GUICtrlToolbar_Create($MAINGUI)
 _GUIImageList_AddIcon($TOOLBAR, @SystemDir & "\shell.dll")
 $IMAGES = _GUIImageList_Create(24,24)
 _GUICtrlToolbar_SetImageList($TOOLBAR, $IMAGES)



 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -1);AndHereIfYouCouldTHX
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, -2)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 3)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 4)
 _GUICtrlToolbar_AddButtonSep($TOOLBAR)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 5)
 _GUICtrlToolbar_AddButton($TOOLBAR, $e_idNew, 6)






GUISetState(@SW_SHOW & $GUI_ACCEPTFILES)


While 1
    $Msg = GUIGetMsg()
    Select

        Case $Msg = $GUI_EVENT_CLOSE
            If _GUICtrlEdit_CanUndo($EDITBOX) Then
                $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?")
                If $SAVECHANGES = 6 And $FILEOPENED = 0 Then
                    SaveAs()
                    _GUICtrlRichEdit_Destroy($hRichEdit)
                    Exit
                EndIf
                If $SAVECHANGES = 6 And $FILEOPENED = 1 Then
                    FileDelete($FILEOPEN)
                    FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
                    Exit
                EndIf
                If $SAVECHANGES = 7 Then
                    ExitLoop
                    Exit
                EndIf
            EndIf
            If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit

        Case $Msg = $OPEN
            $FILEOPEN = FileOpenDialog("Open", $FILEOPEN, $EXT)
            $TEXT = _GUICtrlRichEdit_StreamFromFile($EDITBOX, $FILEOPEN)
            _GUICtrlRichEdit_ReplaceText($EDITBOX, $TEXT)
            $FILEOPENED = 1

        Case $Msg = $NEW
            If _GUICtrlEdit_CanUndo($EDITBOX) Then
                $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?")
                If $SAVECHANGES = 6 And $FILEOPENED = 0 Then
                    SaveAs()
                EndIf
                If $SAVECHANGES = 6 And $FILEOPENED = 1 Then
                    FileDelete($FILEOPEN)
                    FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
                EndIf
                If $SAVECHANGES = 7 Then GUICtrlSetData($EDITBOX, "")
                If $SAVECHANGES = 2 Then Sleep(1)
            EndIf
            If Not _GUICtrlEdit_CanUndo($EDITBOX) Then GUICtrlSetData($EDITBOX, "")
            $FILEOPENED = 0

        Case $Msg = $EXIT
            If _GUICtrlEdit_CanUndo($EDITBOX) Then
                $SAVECHANGES = MsgBox(35, "Text Editor", "Your original file has been modified." & @CRLF & "Would you like to save changes to it?")
                If $SAVECHANGES = 6 And $FILEOPENED = 0 Then
                    SaveAs()
                    _GUICtrlRichEdit_Destroy($hRichEdit)
                    Exit
                EndIf
                If $SAVECHANGES = 6 And $FILEOPENED = 1 Then
                    FileDelete($FILEOPEN)
                    FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
                    Exit
                EndIf
                If $SAVECHANGES = 7 Then ExitLoop
                If $SAVECHANGES = 2 Then
                    Sleep(1)
                EndIf
            EndIf
            If Not _GUICtrlEdit_CanUndo($EDITBOX) Then Exit

        Case $Msg = $SAVEAS
            GUICtrlSetState($EDITBOX, $GUI_DISABLE)
            SaveAs()
            $FILEOPENED = 1
            GUICtrlSetState($EDITBOX, $GUI_ENABLE)

        Case $Msg = $SAVE And $FILEOPENED = 1
            FileDelete($FILEOPEN)
            FileWrite($FILEOPEN, GUICtrlRead($EDITBOX))
            _GUICtrlEdit_EmptyUndoBuffer($EDITBOX)

        Case $Msg = $SAVE And $FILEOPENED = 0
            GUICtrlSetState($EDITBOX, $GUI_DISABLE)
            SaveAs()
            $FILEOPENED = 1
            GUICtrlSetState($EDITBOX, $GUI_ENABLE)

        Case $Msg = $SAVE And $FILEOPENED = 0
            GUICtrlSetState($EDITBOX, $GUI_DISABLE)
            SaveAs()
            $FILEOPENED = 1
            GUICtrlSetState($EDITBOX, $GUI_ENABLE)

        Case $Msg = $PRINT
            $PRINTMSGBOX = MsgBox(35, "Text Editor", "Are you sure you want to print this page?")
            Select

                Case $PRINTMSGBOX = 6
                    If FileExists("Print.txt") Then
                        FileDelete("Print.txt")
                    EndIf
                    FileWrite("Print.txt", GUICtrlRead($EDITBOX))
                    $PRINTFILE = "Print.txt"
                    _FilePrint($PRINTFILE)
                    FileDelete($PRINTFILE)
            EndSelect

        Case $Msg = $UNDO
            _GUICtrlRichEdit_Undo($EDITBOX)

        Case $Msg = $REDO
            _GUICtrlRichEdit_Redo($EDITBOX)

        Case _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 1
            GUICtrlSetState($SAVE, $GUI_ENABLE)

        Case $Msg = $CUT
            _GUICtrlRichEdit_Cut ($EDITBOX)

        Case $Msg = $COPY
            _GUICtrlRichEdit_Copy ($EDITBOX)

        Case $Msg = $PASTE
            _GUICtrlRichEdit_Paste ($EDITBOX)

        Case Not _GUICtrlEdit_CanUndo($EDITBOX) And $SAVES = 0
            GUICtrlSetState($SAVE, $GUI_DISABLE)
            $SAVES = 1
;~       Case $Msg = $FONT
;~          $CHECKFONT = GUICtrlRead($FONTCOMBOBOX)
;~          _GUICtrlRichEdit_SetFont($EDITBOX, $FONTSIZECOMBOBOX, "Times New Roman")

         Case $FONTCOMBOBOX
             $FONTTYPE = GUICtrlRead($FONTCOMBOBOX)
            _GUICtrlRichEdit_SetFont($EDITBOX, "12", $FONTTYPE)
    EndSelect
WEnd
Exit

Func SaveAs()
    $FILESAVEAS = FileSaveDialog("Save As", "", "Text Document (*.txt)|All Files (*.*)")
    If Not @error Then
        $STRING = StringSplit($FILESAVEAS, ".")
        If $STRING[0] = 1 Then
            FileDelete($FILESAVEAS)
            _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf")
        Else
            _GUICtrlRichEdit_StreamToFile($EDITBOX, $FILESAVEAS &".rtf")
        EndIf
    EndIf
 EndFunc


Func _RegEnumVal($sKey)
    Local $i = 1, $sVal, $sResult

    While 1
        $sVal = RegEnumVal($sKey, $i)
        If @error Then ExitLoop
        $i += 1
        $sResult &= $sVal & "|"
    WEnd

    Return StringRegExpReplace($sResult, " \(.*?\)", "")
 EndFunc   ;==>_RegEnumVal

sorry again for bothering everyone

Link to comment
Share on other sites

  • Solution

Yes it does flicker a lot.  But I do not have to courage to debug such a long script.  Here a small reproducer that shows it is working well.

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>

Const $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"

Local $hGUI = GUICreate("Test", 400, 300, 400, 400)

$cCombo_Font = GUICtrlCreateCombo("", 10, 10, 170, 20, BitOR($CBS_SORT, $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL))
GUICtrlSetData($cCombo_Font, _RegEnumVal($sRegKey))

$cLabel = GUICtrlCreateLabel("Font preview", 230, 10, 155, 20)
$idRich = _GUICtrlRichEdit_Create($hGUI, "This is a test.  Long enough to be seen even if the combo is active.  Please select a part that you can see.", 10, 100, 380, 150, $ES_NOHIDESEL)

GUISetState()

While True
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_EVENT_CLOSE
      Exit
    Case $cCombo_Font
      GUICtrlSetFont($cLabel, 10, Default, Default, GUICtrlRead($cCombo_Font))
      _GUICtrlRichEdit_SetFont($idRich, 10, GUICtrlRead($cCombo_Font))
  EndSwitch
WEnd

Func _RegEnumVal($sKey)
  Local $i = 1, $sVal, $sResult

  While 1
    $sVal = RegEnumVal($sKey, $i)
    If @error Then ExitLoop
    $i += 1
    $sResult &= $sVal & "|"
  WEnd

  Return StringRegExpReplace($sResult, " \(.*?\)", "")
EndFunc   ;==>_RegEnumVal

 

Link to comment
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
 Share

×
×
  • Create New...