Modify

Opened 15 years ago

Closed 15 years ago

#1273 closed Bug (Fixed)

_GuiCtrlRichEdit_SetCharColor - example save bad RTF

Reported by: anonymous Owned by: Valik
Milestone: 3.3.1.5 Component: Standard UDFs
Version: 3.3.1.4 Severity: None
Keywords: Cc:

Description

Example for _GuiCtrlRichEdit_SetCharColor() saves RTF file which should contain whole text of richedit control.
But instead of "Paragraph 1" RTF file contains only "aph 1".

Note: In this example parts of word was formatted differently

So maybe this is more related (bug) in _GuiCtrlRichEdit_StreamToFile() but I'm not sure about the place where is cause of this bug.

Example from helpfile:

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Color.au3>

Opt('MustDeclareVars', 1)

Global $lblMsg, $hRichEdit

Main()

Func Main()
    Local $hGui, $iMsg, $btnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName,4) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $lblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $btnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState()

    _GuiCtrlRichEdit_SetText($hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                GUIDelete()
                Exit
            Case $iMsg = $btnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GuiCtrlRichEdit_SetCharColor($hRichEdit, "304050")
                        Report("2. Setting is now")
                    Case 3
                        _GuiCtrlRichEdit_SetSel($hRichEdit, 1, 5)
                        _GuiCtrlRichEdit_SetCharColor($hRichEdit)
                        Report("3. Background of a few characters changed")
                    Case 4
                        _GuiCtrlRichEdit_SetSel($hRichEdit, 6, -1)
;~                      _GuiCtrlRichEdit_Deselect($hRichEdit)
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GuiCtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")
                        Report("4. Saved to File")
                        GUICtrlSetState($btnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Main

Func Report($sMsg)
    Local $iColor = _GUICtrlRichEdit_GetCharColor($hRichEdit)
    Local $sMixed = _Iif(@extended, "+", "~")
    Local $aRet = _ColorGetRGB($iColor)
    $sMsg = $sMsg & @CR & @CR & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " Color=0x" & Hex($iColor) & ":" & $sMixed
    GUICtrlSetData($lblMsg, $sMsg)
    ControlFocus($hRichEdit, "", "")
EndFunc   ;==>Report

Change History (3)

comment:1 Changed 15 years ago by Zedna

I forgot to fill my nick in this ticket.

comment:2 Changed 15 years ago by Zedna

Sorry.
Please mark this ticket as NO BUG. or maybe only correct DOC (comment in example).
Now I noticed in description for _GuiCtrlRichEdit_StreamToFile()

If text is selected, writes only the selection, else writes all text in the control

Originally I saw the comment in example for _GUICtrlRichEdit_SetCharColor() saying

; Stream all text to the Desktop so you can look at settings in Word
                        _GuiCtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")

so I expected it should save whole text.

comment:3 Changed 15 years ago by Valik

  • Milestone set to 3.3.1.5
  • Owner changed from Gary to Valik
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5361] in version: 3.3.1.5

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.