;~ AutoIt Version: 3.3.14.5
;~ Author: Tempo
#include <GUIConstants.au3>
#include <GuiEdit.au3>
#include <WinAPIShellEx.au3>
example()
Func example()
ClipPut('Line 1' & @LF & 'Line 2' & @LF & 'Line 3' & @LF & 'Line 4' & @LF & '...')
Local $hGui = GUICreate(@ScriptName, 400, 400)
Local $idEdit = GUICtrlCreateEdit('', 0, 0, 400, 350, -1, 0)
editEnableAddCR(-1)
Local $idButton_Read = GUICtrlCreateButton('GUICtrlRead', 10, 360, 380, 30)
GUISetState()
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton_Read
MsgBox(0, Default, StringReplace(StringReplace(GUICtrlRead($idEdit), @CR, '{CR}'), @LF, '{LF}'), 0, $hGui)
EndSwitch
WEnd
EndFunc ;==>example
Func editEnableAddCR($hEdit, $bEnable = True)
Local Static $s_pEditProc = DllCallbackGetPtr(DllCallbackRegister(editSubclassProc, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr'))
Return ($bEnable ? _WinAPI_SetWindowSubclass : _WinAPI_RemoveWindowSubclass)(IsHWnd($hEdit) ? $hEdit : GUICtrlGetHandle($hEdit), $s_pEditProc, 5000)
EndFunc ;==>editEnableAddCR
Func editSubclassProc($hWnd, $iMsg, $wParam, $lParam, $iSubclass, $pData)
#forceref $iSubclass, $pData
If $iMsg = $WM_PASTE Then
_GUICtrlEdit_AppendText($hWnd, StringAddCR(ClipGet()))
Return
EndIf
Return DllCall('comctl32.dll', 'lresult', 'DefSubclassProc', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam)[0]
EndFunc ;==>editSubclassProc