Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
horizontal scroll issues (WM_HSCROLL)
#1
The horizontal scroll doesn't work fully correctly.
In the below dialog I want to find and focus on 'Z' (capital), there are 3 of them in the multi-line control.

* Without extended ASCII char (first line removed)
If you remove the first line with the extended ASCII char. The find almost works like it's intended.
The problem is when after the first search (first time you hit button "find") the scroll is set to the right because of the first 'Z', the issue starts here because
the second 'Z' is at the beginning of the next line BUT the scrollbar doesn't scroll back to it (even if I change 'x-10' to 'x') , at case 4 last line

* With extended ASCII char (first line not removed:    │ -> extended ASCII character )
The first time you click "find" the first 'Z' is located and selected correctly but then it is stuck at that first search result.

The below used "IndexToUtf16" comes from:  https://www.libreautomate.com/forum/show...p?tid=7782

I tried resetting the scroll back to beginning using:
SendDlgItemMessage hDlg 3 WM_HSCROLL 0 0
But it didn't work for me


Function hscroll_test2
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 196 60 "Dialog" "4"
;3 Edit 0x54321044 0x200 6 8 124 48 ""
;4 Button 0x54032000 0x0 142 10 44 14 "find: Z"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3=
;│ -> extended ASCII character
;ABCDEFGHIJKLMNOPQRSTUVQXYZ...test...0123456789
;ABCZDEFGHIJKLMNOPQRSTUVQXYZ...test...0123456789
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,int x y
,,ARRAY(CHARRANGE) charranges
,,int- f
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4
,,act id(3 hDlg)
,,str txt.getwintext(id(3 hDlg))
,,str findchar="Z" ;; find 'Z' (capital)
,,findrx(txt F"\Q{findchar}\E" f 4|8 charranges)
,,if(charranges.len=0) ;; Set the caret, h-scroll and vscroll back to 0. reset 'f' and return
,,,f=0
,,,SendDlgItemMessage hDlg 3 WM_VSCROLL MakeInt(SB_THUMBPOSITION 0) 0
,,,SendDlgItemMessage hDlg 3 WM_HSCROLL MakeInt(SB_THUMBPOSITION 0) 0
,,,SendMessage(id(3 hDlg) EM_SETSEL 0 0)
,,,ret        
,,SendMessageW(id(3 hDlg) EM_SETSEL txt.IndexToUtf16(charranges[0 0].cpMin) txt.IndexToUtf16(charranges[0 0].cpMax)) ;; IndexToUtf16 -> https://www.libreautomate.com/forum/showthread.php?tid=7782       
,,f=txt.IndexToUtf16(charranges[0 0].cpMin)+1 ;; Need to do + 1 or else we keep stuck at the current search result
,,sub.get_pos_sel(hDlg x y) ;; Below 'WM_HSCROLL' needs x-position of the selection
,,SendDlgItemMessage hDlg 3 WM_HSCROLL MakeInt(SB_THUMBPOSITION x-10) 0 ;; need to do -10 or else the selection falls out of control view (need to find better solution for this)
,,
ret 1



#sub get_pos_sel
function int'hDlg int&x int&y

;; This get's the X/Y pos of the selection in the multiline control (we only need X)

int selStart selEnd         
SendMessage(id(3 hDlg), EM_GETSEL, &selStart, &selEnd)
int i = SendMessage(id(3 hDlg), EM_POSFROMCHAR, selStart, 0)         
x=i & 0xFFFF
y=i >> 16
#2
Code:
Copy      Help
,,SendMessageW(id(3 hDlg) EM_SETSEL txt.IndexToUtf16(charranges[0 0].cpMin) txt.IndexToUtf16(charranges[0 0].cpMax)) ;; IndexToUtf16 -> https://www.libreautomate.com/forum/showthread.php?tid=7782       
,,f=txt.IndexToUtf16(charranges[0 0].cpMin)+1 ;; Need to do + 1 or else we keep stuck at the current search result

->
 
Code:
Copy      Help
,,SendDlgItemMessage hDlg 3 WM_VSCROLL SB_TOP 0
,,SendDlgItemMessage hDlg 3 WM_HSCROLL SB_LEFT 0
,,SendMessageW(id(3 hDlg) EM_SETSEL txt.IndexToUtf16(charranges[0 0].cpMin) txt.IndexToUtf16(charranges[0 0].cpMax)) ;; IndexToUtf16 -> https://www.libreautomate.com/forum/showthread.php?tid=7782
,,f=charranges[0 0].cpMin+1 ;; Need to do + 1 or else we keep stuck at the current search result
#3
Thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)