Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Edit control modifies the current line of text
#8
sorry got busy with other things

this line is incorrect
int lineLength = SendMessage(h EM_LINELENGTH line 0)
 cannot be line number
must be character index

this should do what you want

Code:
Copy      Help
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
,int cid=id(3 hDlg)
,sub.SetCurLine(cid "_____")
ret 1

#sub SetCurLine
function h str's
int x y
GetCaretXY(x y 0 0 1)
int lh=MakeInt(x y)
int cursorPos = SendMessage(h EM_CHARFROMPOS 0 lh)
int cpos line
cpos = cursorPos&0xFFFF
line = cursorPos>>16
int lineStart = SendMessage(h EM_LINEINDEX line 0)
int lineLength = SendMessage(h EM_LINELENGTH cpos 0)
int lineEnd = lineStart + lineLength
SendMessage(h EM_SETSEL lineStart lineEnd)
_s.getsel
_s+ s
SendMessageW h EM_REPLACESEL 1 @_s


Messages In This Thread
RE: Edit control modifies the current line of text - by Kevin - 02-27-2023, 05:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)