Opened 14 years ago

Closed 14 years ago

#1466 closed Bug (Fixed)

_GUICtrlEdit_GetLine returns an unexpected character

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


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 Changed 14 years ago by Jon

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

Fixed by revision [5712] in version:

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

Modify Ticket

as closed The owner will remain Jon.

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

Note: See TracTickets for help on using tickets.