02-11-2016, 11:43 AM
I have the following situation.
2 multiline inputfields, the left multiline inputfield is read-only and vscroll is removed.
The left multiline inputfield shows linenumbers which get updated as soon the user modfies something the right inputfield.
The problem is that the when the RIGHT inputfield get's scrolled only the contents of the right inputfield get's scrolled which is as is expected. However I want to scroll the the LEFT inputfield (showing linenumbers) also to be scrolled at same position as RIGHT inputfield.
How do I set scroll-view of the left inputfield based on the right inputfield?
Function line_numbers_example
2 multiline inputfields, the left multiline inputfield is read-only and vscroll is removed.
The left multiline inputfield shows linenumbers which get updated as soon the user modfies something the right inputfield.
The problem is that the when the RIGHT inputfield get's scrolled only the contents of the right inputfield get's scrolled which is as is expected. However I want to scroll the the LEFT inputfield (showing linenumbers) also to be scrolled at same position as RIGHT inputfield.
How do I set scroll-view of the left inputfield based on the right inputfield?
Function line_numbers_example
\Dialog_Editor
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 176 78 "line numbers+scroll example"
;3 Edit 0x54031844 0x200 27 4 18 37 ""
;4 Edit 0x54231044 0x200 48 4 122 37 ""
;1 Button 0x54030001 0x4 68 56 48 14 "OK"
;2 Button 0x54030000 0x4 120 56 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040301 "*" "" "" ""
str controls = "3 4"
str e3 e4
e4="line_1[]line_2[]line_3[]line_4"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,,sub.SetLineNumbers(hDlg) ;; Must pass 'hDlg', even when using 'v' parameter in subfunction 'hDlg' does not get recognized.
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case EN_CHANGE<<16|4
,,sub.SetLineNumbers(hDlg)
ret 1
;
#sub SetLineNumbers
function int'h_dlg
,int i
,str get_lns set_lns
,get_lns.getwintext(id(4 h_dlg))
,get_lns.trim
,ARRAY(str) ln_arr.create(numlines(get_lns))
,for i 0 ln_arr.len
,,ln_arr[i]=i+1
,_s=ln_arr
,_s.setwintext(id(3 h_dlg))