Opened 5 years ago

Last modified 4 years ago

#3555 closed Bug

_GUICtrlRichEdit_StreamToVar with > 2048 characters — at Version 2

Reported by: anthonyjr2 Owned by:
Milestone: Component: Standard UDFs
Version: 3.3.14.2 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

This bug was discussed and solved here: https://www.autoitscript.com/forum/topic/188643-is-_guictrlrichedit_streamtovar-limited-to-2048-chars/

The problem happens when trying to stream a RichEdit with length > 2048 to a variable with _GUICtrlRichEdit_StreamToVar. The stream to file works correctly in this matter. The problem lies within this code which is called by the function:

Func __GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)
	#forceref $iCookie
	Local $tQbytes = DllStructCreate("long", $pQbytes)
	DllStructSetData($tQbytes, 1, 0)
	Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
	Local $s = DllStructGetData($tBuf, 1)
	$__g_pGRC_sStreamVar &= $s
	Return 0
EndFunc   ;==>__GCR_StreamToVarCallback

The buffer is not updated correctly at the end of the function. The solution is to add a line before the return statement and modify the earlier struct set:

Func __GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)
	#forceref $iCookie
	Local $tQbytes = DllStructCreate("long", $pQbytes)
	DllStructSetData($tQbytes, 1, $iBuflen) ;Modified this line
	Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
	Local $s = DllStructGetData($tBuf, 1)
	$__g_pGRC_sStreamVar &= $s
	DllStructSetData($tQbytes, 1, StringLen($s)) ;Added this line
	Return 0
EndFunc   ;==>__GCR_StreamToVarCallback

This correctly updates the struct and solves the character limit.

Change History (2)

comment:1 Changed 5 years ago by anonymous

Func GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)

#forceref $iCookie
	Local $tQbytes = DllStructCreate("long", $pQbytes)
	DllStructSetData($tQbytes, 1, 0)
	Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
	Local $s = DllStructGetData($tBuf, 1)
	$__g_pGRC_sStreamVar &= $s
	DllStructSetData($tQbytes, 1, StringLen($s))
	Return 0

EndFunc ;==>GCR_StreamToVarCallback

I didn't realize the editor messed up my code a bit. This should be better.

comment:2 Changed 5 years ago by mLipok

  • Description modified (diff)
Note: See TracTickets for help on using tickets.