02-26-2023, 09:55 AM
Hi,
The following code,Use Hotkey Alt+A, can append text to the current line in the edit box, but there will be errors when operating the second line. Please see the following picture
![[Image: 1677664520]](https://download.ru/g/uwqRHLhk/7JMZ3Tr2ZZkVl6dUQvprGA/1677664520)
Macro Macro6
The following code,Use Hotkey Alt+A, can append text to the current line in the edit box, but there will be errors when operating the second line. Please see the following picture
Macro Macro6
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 8 8 208 102 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""
str controls = "3"
str e3
e3=
;AAAAAAAAAAAAAAAAAAAAAAAAAA
;BBBBBBBBBBBBBBBBBBBBBBBBBB
;CCCCCCCCCCCCCCCCCCCCCCCCCC
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "401 Aa"
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 401
,sub.SetCurLine id(3 hDlg) "_____"
ret 1
#sub SetCurLine
function h str's
POINT p; xm(p)
int char = SendMessage(h EM_CHARFROMPOS p.x p.y)
int line = SendMessage(h EM_LINEFROMCHAR char 0)
int lineStart = SendMessage(h EM_LINEINDEX line 0)
int lineLength = SendMessage(h EM_LINELENGTH line 0)
int lineEnd = lineStart + lineLength
SendMessage(h EM_SETSEL lineStart lineEnd)
_s.getsel
_s+F"{s}"
SendMessageW h EM_REPLACESEL 0 @_s