Modify ↓
      
        Opened 12 years ago
Closed 12 years ago
#2700 closed Bug (Fixed)
_GUICtrlRichEdit_SetCharBkColor()
| Reported by: | mLipok | Owned by: | Jpm | 
|---|---|---|---|
| Milestone: | 3.3.11.5 | Component: | Standard UDFs | 
| Version: | 3.3.11.4 | Severity: | None | 
| Keywords: | Cc: | 
Description
from HelpFile:
Sets the background color of selected text or, if none selected, sets the background color of text inserted at the insertion point
here is a solution to the UDF:
    If $ai[0] = $ai[1] Then
;~      Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_ALL, $tCharFormat, 0, "wparam", "struct*") <> 0
        Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") <> 0
    Else
        Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") <> 0
    EndIf
And solution after cleaning, just do not use If the else statement just use:
Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") <> 0
MS DOC:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774230(v=vs.85).aspx
SCF_SELECTION Applies the formatting to the current selection. If the selection is empty, the character formatting is applied to the insertion point, and the new character format is in effect only until the insertion point changes.
Attachments (0)
Change History (2)
comment:1 Changed 12 years ago by mLipok
comment:2 Changed 12 years ago by Jpm
- Milestone set to 3.3.11.5
- Owner set to Jpm
- Resolution set to Fixed
- Status changed from new to closed
Fixed by revision [10091] in version: 3.3.11.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.
Note: See
        TracTickets for help on using
        tickets.
    

sorry
I forgot REPRO:
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) Local $sText = _ "ABCD" & @CRLF & _ "EEEE" & @CRLF & _ "AAAA" & @CRLF & _ "" $hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 100, 100, 150, 150) _Magic($hRichEdit, $sText) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Magic(ByRef $hRichEdit, $sText) Local $aTextTemp = StringSplit($sText, @CRLF, 1) For $i = 1 To $aTextTemp[0] _GUICtrlRichEdit_SetSel($hRichEdit,-1,-1) Sleep(100) ; this can be removed _GUICtrlRichEdit_SetCharBkColor($hRichEdit, Dec("00FF00")) Sleep(100); this can be removed _GUICtrlRichEdit_InsertText($hRichEdit, $i) Sleep(100); this can be removed _GUICtrlRichEdit_SetSel($hRichEdit,-1,-1) Sleep(100); this can be removed _GUICtrlRichEdit_SetCharBkColor($hRichEdit, Dec("FFFFFF")) Sleep(100); this can be removed _GUICtrlRichEdit_InsertText($hRichEdit, " " & $aTextTemp[$i] & @CRLF) Sleep(100); this can be removed Next EndFunc ;==>_Magic