Sign in to follow this  
Followers 0
VoSs2o0o

_GUICtrlEditGetLine API - Bug

2 posts in this topic

Hi,

I have wondered why my current program give me some strange values, and i have found more about a windows bug in google,

The EM_GETLINE Message works not correctly somethimes. A "better" _GUICtrlEditGetLine should be:

;===============================================================================
;
; Description:          _GUICtrlEditGetLine
; Parameter(s):     $h_edit - controlID
;                           $i_line - Specifies the line to be retrieved.
; Requirement:          None
; Return Value(s):  Returns the line from the multiline edit control.
;                           If an error occurs, the return value is "" (empty string) and @error is set.
; User CallTip:     _GUICtrlEditGetLine($h_edit, $i_line) Copies a line of text from an edit control. (required: <GuiEdit.au3>)
; Author(s):            Gary Frost (custompcs at charter dot net)
;                           Jos van der Zande <jdeb at autoitscript com >
; Note(s):
;
;===============================================================================
Func _GUICtrlEditGetLine(ByRef $h_Edit, $i_line)
    Local $i_index = _GUICtrlEditLineIndex($h_Edit, $i_line)
    If @error Then Return SetError($EC_ERR, $EC_ERR, "")
    ;Local $length = _GUICtrlEditLineLength($h_Edit, $i_index) ;not needed
    ;If @error Then Return SetError($EC_ERR, $EC_ERR, "")      ;not needed
         Local $length = 1024 - 2                              ;better way to make sure that you have the complete line readed
    Local $struct_Buffer = DllStructCreate("short;char[" & $length + 2 & "]")
    If @error Then Return SetError($EC_ERR, $EC_ERR, "")
    DllStructSetData($struct_Buffer, 1, $length, 1)
    If IsHWnd($h_Edit) Then
        _SendMessage($h_Edit, $EM_GETLINE, $i_line - 1, DllStructGetPtr($struct_Buffer))
        If @error Then Return SetError($EC_ERR, $EC_ERR, "")
    Else
        GUICtrlSendMsg($h_Edit, $EM_GETLINE, $i_line - 1, DllStructGetPtr($struct_Buffer))
        If @error Then Return SetError($EC_ERR, $EC_ERR, "")
    EndIf
    Local $struct_String = DllStructCreate("char[" & $length & "]", DllStructGetPtr($struct_Buffer))    
    If @error Then Return SetError($EC_ERR, $EC_ERR, "")
    Return DllStructGetData($struct_String, 1)
EndFunc   ;==>_GUICtrlEditGetLine

replace the old UDF in AutoIt\include\GuiEdit.au3 with this version to fix that problem.

I don't have posted it to the Bug-Forum, because its "only" a Windows Bug since Windows 2000,

the AutoIt code is correct and in other Windows versions it works stable (including the new Vista? :whistle::) )


AutoItMacroGenerator on my Homepage (Link 2)

Share this post


Link to post
Share on other sites



Hi,

I have wondered why my current program give me some strange values, and i have found more about a windows bug in google,

The EM_GETLINE Message works not correctly somethimes. A "better" _GUICtrlEditGetLine should be:

replace the old UDF in AutoIt\include\GuiEdit.au3 with this version to fix that problem.

I don't have posted it to the Bug-Forum, because its "only" a Windows Bug since Windows 2000,

the AutoIt code is correct and in other Windows versions it works stable (including the new Vista? :whistle::) )

Mind explaining better what versions of windows you think it is a bug in?

Just ran it in Win2k Pro SP4 with no problems, and WinXP Pro SP2 also with no problems.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0