Modify ↓
Opened 16 years ago
Closed 16 years ago
#1441 closed Bug (Fixed)
_GUICtrlRichEdit_GetText: last character truncated
| Reported by: | ProgAndy | Owned by: | Jon |
|---|---|---|---|
| Milestone: | 3.3.5.4 | Component: | Standard UDFs |
| Version: | 3.3.5.1 | Severity: | None |
| Keywords: | Cc: |
Description
_GUICtrlRichEdit_GetText sets the length of the string-buffer incorrect. This results in a missing character at the end of the string.
This is the fixed function:
; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlRichEdit_GetText
; Description ...: Get all of the text in the control
; Syntax ........: _GUICtrlRichEdit_GetText($hWnd[, $fCrToCrLf = False[, $iCodePage = 0[, $sReplChar = ""]]])
; Parameters ....: $hWnd - Handle to control
; $fCrToCrLf - Convert each CR to a CrLf (Optional)
; |True - do it
; | don't (Default)
; $iCodePage - code page used in translation (Optional)
; |Default: use system default
; |CP_ACP for ANSI, 1200 for Unicode
; $sReplaChar - Character used if $iCodePage is not 1200 and a wide character cannot be represented in
; +specified code page (Optional)
; Return Values. : Success - the text
; Failure - "" and sets @error:
; |101 - $hWnd is not a handle
; |102 - $fCrToCrLf must be True or False
; |103 - $iCodePage is not a number
; |700 - internal error
; Authors........: Prog@ndy
; Modified ......: Chris Haslam (c.haslam), jpm, Prog@ndy
; Remarks .......: On success, if $sReplChar set, @extended contains whether this character was used
;+
; Call _GUICtrlRichEdit_IsModified() to determine whether the text has changed
; Related .......: _GUICtrlRichEdit_SetText, _GUICtrlRichEdit_AppendText, _GUICtrlRichEdit_InsertText, _GUICtrlRichEdit_IsModified
; Link ..........: @@MsdnLink@@ EM_GETTEXTEX
; Example .......: Yes
; ===============================================================================================================================
Func _GUICtrlRichEdit_GetText($hWnd, $fCrToCrLf = False, $iCodePage = 0, $sReplChar = "")
If Not IsHWnd($hWnd) Then Return SetError(101, 0, "")
If Not IsBool($fCrToCrLf) Then Return SetError(102, 0, "")
If Not __GCR_IsNumeric($iCodePage) Then Return SetError(103, 0, "")
Local $iLen = _GUICtrlRichEdit_GetTextLength($hWnd, False,True) + 1
Local $sUni=''
If $iCodePage=$CP_UNICODE Or Not $iCodePage Then $sUni="w"
Local $tText = DllStructCreate($sUni & "char[" & $iLen & "]")
Local $tGetTextEx = DllStructCreate($tagGETTEXTEX)
DllStructSetData($tGetTextEx, "cb", DllStructGetSize($tText))
Local $iFlags = 0
If $fCrToCrLf Then $iFlags = $GT_USECRLF
DllStructSetData($tGetTextEx, "flags", $iFlags)
If $iCodePage = 0 Then $iCodePage = $CP_UNICODE
DllStructSetData($tGetTextEx, "codepage", $iCodePage)
Local $pUsedDefChar = 0, $pDefaultChar = 0
If $sReplChar <> "" Then
Local $tDefaultChar = DllStructCreate("char")
$pDefaultChar = DllStructGetPtr( $tDefaultChar, 1)
DllStructSetData( $tDefaultChar, 1, $sReplChar)
Local $tUsedDefChar = DllStructCreate("bool")
$pUsedDefChar = DllStructGetPtr( $tUsedDefChar, 1)
EndIf
DllStructSetData($tGetTextEx, "lpDefaultChar", $pDefaultChar)
DllStructSetData($tGetTextEx, "lpbUsedDefChar", $pUsedDefChar)
Local $iRet = _SendMessage($hWnd, $EM_GETTEXTEX, DllStructGetPtr($tGetTextEx), DllStructGetPtr($tText))
If $iRet = 0 Then Return SetError(700, 0, "")
If $sReplChar <> "" Then SetExtended(DllStructGetData($tUsedDefChar, 1) <> 0)
Return DllStructGetData($tText, 1)
EndFunc ;==>_GUICtrlRichEdit_GetText
Attachments (0)
Change History (1)
comment:1 Changed 16 years ago by Jon
- Milestone set to 3.3.5.4
- Owner changed from Gary to Jon
- Resolution set to Fixed
- Status changed from new to closed
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.

Fixed by revision [5670] in version: 3.3.5.4