Modify

Opened 16 years ago

Closed 16 years ago

#1466 closed Bug (Fixed)

_GUICtrlEdit_GetLine returns an unexpected character

Reported by: ProgAndy Owned by: Jon
Milestone: 3.3.5.5 Component: Standard UDFs
Version: 3.3.5.3 Severity: None
Keywords: Cc:

Description

When using _GUICtrlEdit_GetLine, an unexpected character is appended. Here is the corrected function.

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlEdit_GetLine
; Description ...: Retrieves a line of text from an edit control
; Syntax.........: _GUICtrlEdit_GetLine($hWnd, $iLine)
; Parameters ....: $hWnd        - Handle to the control
;                  $iLine       - Zero-based line index to get
; Return values .: Success      - The line of text
;                  Failure      - Empty string
; Author ........: Gary Frost (gafrost), Jos van der Zande <jdeb at autoitscript com >
; Modified.......: Gary Frost (gafrost)
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _GUICtrlEdit_GetLine($hWnd, $iLine)
	If $Debug_Ed Then __UDF_ValidateClassName($hWnd, $__EDITCONSTANT_ClassName)
	If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

	Local $iLength = _GUICtrlEdit_LineLength($hWnd, $iLine)
	If $iLength = 0 Then Return ""
	Local $tBuffer = DllStructCreate("short Len;wchar Text[" & $iLength & "]")
	Local $pBuffer = DllStructGetPtr($tBuffer)
	DllStructSetData($tBuffer, "Len", $iLength + 1)
	Local $iRet = _SendMessage($hWnd, $EM_GETLINE, $iLine, $pBuffer, 0, "wparam", "ptr")

	If $iRet = 0 Then Return SetError($EC_ERR, $EC_ERR, "")

	Local $tText = DllStructCreate("wchar Text[" & $iLength & "]", $pBuffer)
	Return DllStructGetData($tText, "Text")
EndFunc   ;==>_GUICtrlEdit_GetLine

Attachments (0)

Change History (1)

comment:1 by Jon, 16 years ago

Milestone: 3.3.5.5
Owner: changed from Gary to Jon
Resolution: Fixed
Status: newclosed

Fixed by revision [5712] in version: 3.3.5.5

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.