Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamically create SysListView
#31
From my testing  the control itself is the problem. The messages are received but the control(SysListView32) has a delay or ignores the message.  Going to test virtual listview and see if it is better later not near pc with qm installed
#32
Quote:Going to test virtual listview and see if it is better later not near pc with qm installed

I don't quite understand what that means
#33
this version is with QM Grid. Don't need function DynamicLVKeys with this.

everything works accept tab. Can't make work with grid. So, you will have to use enter instead of tab.
Function DynamicLV2
Code:
Copy      Help
;/
function# str'text [flags];;optional .1 show dialog at caret position if possible. 0 or omitted show dialog at center of screen(default)
int w1=win()
RECT r1; DpiGetWindowRect w1 &r1
int iid to=Statement(1 0 0 iid)
str ss.getmacro(iid)
ss.left(ss to)
if(flags&1)
,int xx yy isCaret
,isCaret = GetCaretXY(xx yy)

str dd=
;BEGIN DIALOG
;0 "" 0x90080AC8 0x0 0 0 184 108 "" "4"
;3 QM_Grid 0x5603504D 0x200 0 0 184 108 "0x13,0,0,0x4,0x0[]"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str qmg3x
int iii= ShowDialog(dd &sub.DlgProc &controls)
ret iii

#sub DlgProc v
function# hDlg message wParam lParam
DlgGrid g.Init(hDlg 3)
sel message
,case WM_INITDIALOG
,__Font- f.CreateNew(g.hwnd "Segoe UI" 12) ;;change this
,f.SetDialogFont(hDlg "3")
,g.ColumnsAdd(",90%[],10%")
,int n=numlines(text)
,for int'i 0 n
,,_s.getl(text i)
,,TO_LvAdd g.hwnd i 0 0 _s i+1
,RECT r.left=LVIR_BOUNDS; SendMessage(g.hwnd LVM_GETITEMRECT 0 &r)
,int xy=SendMessage(g.hwnd LVM_APPROXIMATEVIEWRECT n -1|-1)
,int width = xy & 0x0000FFFF
,int hh = xy>>16&0x0000FFFF
,siz width+4 hh g.hwnd
,siz width+11 hh-r.bottom+8 hDlg
,if(isCaret > 0) ;; if caret is found  and flag is 1 move dialog to caret
,,mov xx yy+25 hDlg
,else
,,int Dwidth Dheight
,,GetWinXY hDlg 0 0 Dwidth Dheight
,,int Dx = r1.left + ((r1.right - r1.left - Dwidth)/2)
,,int Dy = r1.top + ((r1.bottom - r1.top - Dheight)/2)
,,mov Dx Dy hDlg    
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3    
ret
;messages2
sel wParam
,case IDOK
,int ii=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
,DT_EndDialog(hDlg ii)    
,case IDCANCEL
,DT_EndDialog(hDlg 1000)
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3
,GRID.QM_NMLVDATA* cd=+nh
,NMLVDISPINFO* di=+nh
,NMLISTVIEW* nlv=+nh
,NMITEMACTIVATE* na=+nh
,sel nh.code
,,case NM_DBLCLK ;;when user clicks a row or empty space, and it does not begin cell edit mode
,,DT_EndDialog(hDlg na.iItem)
,,case NM_RCLICK
,,str lviText.getl(text na.iItem)
,,int posF=find(ss lviText 0)
,,mac "sub.CloseMenu"
,,mac "sub.FlashCodeLine" "" posF iid
,,DT_EndDialog(hDlg 1000)
,,ret 0
,,case LVN_KEYDOWN
,,NMLVKEYDOWN* lvk=+nh
,,if lvk.wVKey =188;; key ,
,,,SendMessage(g.hwnd WM_KEYDOWN VK_DOWN 0)
,,,ret 1
,,if lvk.wVKey =190    ;; key .
,,,SendMessage(g.hwnd WM_KEYDOWN VK_UP 0)
,,,ret 1
,,if lvk.wVKey=191;; key /
,,,DT_EndDialog(hDlg 1000)
,,if(lvk.wVKey>64 or lvk.wVKey<91)
,,,str gg
,,,QmKeyCodeFromVK lvk.wVKey gg
,,,opt waitmsg 1
,,,int ln dc=sub.CheckForUnique(text lvk.wVKey ln)
,,,act hDlg
,,,if dc>1
,,,,int row
,,,,for row 0 g.RowsCountGet
,,,,,str s=g.CellGet(row 0)
,,,,,if s.begi(gg)
,,,,,,int rs=g.RowSelectedGet
,,,,,,if rs=row
,,,,,,,continue
,,,,,,else
,,,,,,,g.RowSelect(row)
,,,,,,,break
,,,if dc=1
,,,,DT_EndDialog(hDlg ln)

#sub CheckForUnique
function ~text keys &ln
;out keys
int count
for _i 0 numlines(text)
,_s.getl(text _i)
,if(_s[0] = keys)
,,ln=_i
,,count+1
ret count

#sub FlashCodeLine
function curPos iid [hce]
if(!hce) hce=GetQmCodeEditor
mac+ iid
act hce
SendMessage hce SCI.SCI_GOTOPOS curPos 0
int indicator=19
SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0)
SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100)
SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00)
SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX)
SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE)
int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0)
int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0)
act hce
rep 4
,SendMessage(hce SCI.SCI_INDICATORFILLRANGE curPos lep-curPos)
,0.25
,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE curPos lep-curPos)
,0.25
SendMessage(hce SCI.SCI_SETINDICATORCURRENT 0 0)

#sub CloseMenu
int w=wait(0 WV win("" "#32768"))
clo w
#34
The work is stable now,thank you so much
#35
@kevin
Switching error when the number of items is greater than 2

[Image: 1680056107]



Code:
Copy      Help
_s=
;A  I'm in the line A1
;A  I'm in the line A2
;A  I'm in the line A3
;A  I'm in the line A4
;B  I'm in the line B1
;B  I'm in the line B2
;C  I'm in the line C
;D  I'm in the line D1
;D  I'm in the line D2
;E  I'm in the line E
;F  I'm in the line F1
;F  I'm in the line F2
;
_i=DynamicLV91(_s 1)
if _i=1000
,ret;; end if alt+f4 or esc was used to closed dialog
str ss
ss.getl(_s _i)
mes ss
#36
this should take care of that

Function DynamicLV2
Code:
Copy      Help
;/
function# str'text [flags];;optional .1 show dialog at caret position if possible. 0 or omitted show dialog at center of screen(default)
int w1=win()
RECT r1; DpiGetWindowRect w1 &r1
int iid to=Statement(1 0 0 iid)
str ss.getmacro(iid)
ss.left(ss to)
if(flags&1)
,int xx yy isCaret
,isCaret = GetCaretXY(xx yy)

str dd=
;BEGIN DIALOG
;0 "" 0x90080AC8 0x0 0 0 184 108 "" "4"
;3 QM_Grid 0x5603504D 0x200 0 0 184 108 "0x13,0,0,0x4,0x0[]"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str qmg3x
int iii= ShowDialog(dd &sub.DlgProc &controls)
ret iii

#sub DlgProc v
function# hDlg message wParam lParam
DlgGrid g.Init(hDlg 3)
sel message
,case WM_INITDIALOG
,__Font- f.CreateNew(g.hwnd "Segoe UI" 12) ;;change this
,f.SetDialogFont(hDlg "3")
,g.ColumnsAdd(",90%[],10%")
,int n=numlines(text)
,for int'i 0 n
,,_s.getl(text i)
,,TO_LvAdd g.hwnd i 0 0 _s i+1
,RECT r.left=LVIR_BOUNDS; SendMessage(g.hwnd LVM_GETITEMRECT 0 &r)
,int xy=SendMessage(g.hwnd LVM_APPROXIMATEVIEWRECT n -1|-1)
,int width = xy & 0x0000FFFF
,int hh = xy>>16&0x0000FFFF
,siz width+4 hh g.hwnd
,siz width+11 hh-r.bottom+8 hDlg
,if(isCaret > 0) ;; if caret is found  and flag is 1 move dialog to caret
,,mov xx yy+25 hDlg
,else
,,int Dwidth Dheight
,,GetWinXY hDlg 0 0 Dwidth Dheight
,,int Dx = r1.left + ((r1.right - r1.left - Dwidth)/2)
,,int Dy = r1.top + ((r1.bottom - r1.top - Dheight)/2)
,,mov Dx Dy hDlg    
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3    
ret
;messages2
sel wParam
,case IDOK
,int ii=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
,DT_EndDialog(hDlg ii)    
,case IDCANCEL
,DT_EndDialog(hDlg 1000)
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3
,GRID.QM_NMLVDATA* cd=+nh
,NMLVDISPINFO* di=+nh
,NMLISTVIEW* nlv=+nh
,NMITEMACTIVATE* na=+nh
,sel nh.code
,,case NM_DBLCLK ;;when user clicks a row or empty space, and it does not begin cell edit mode
,,DT_EndDialog(hDlg na.iItem)
,,case NM_RCLICK
,,str lviText.getl(text na.iItem)
,,int posF=find(ss lviText 0)
,,mac "sub.CloseMenu"
,,mac "sub.FlashCodeLine" "" posF iid
,,DT_EndDialog(hDlg 1000)
,,ret 0
,,case LVN_KEYDOWN
,,NMLVKEYDOWN* lvk=+nh
,,if lvk.wVKey =188;; key ,
,,,SendMessage(g.hwnd WM_KEYDOWN VK_DOWN 0)
,,,ret 1
,,if lvk.wVKey =190    ;; key .
,,,SendMessage(g.hwnd WM_KEYDOWN VK_UP 0)
,,,ret 1
,,if lvk.wVKey=191;; key /
,,,DT_EndDialog(hDlg 1000)
,,if(lvk.wVKey>64 or lvk.wVKey<91)
,,,str gg
,,,QmKeyCodeFromVK lvk.wVKey gg
,,,opt waitmsg 1
,,,int ln dc=sub.CheckForUnique(text lvk.wVKey ln)
,,,act hDlg
,,,if dc>1
,,,,int row
,,,,for row 0 ln+1
,,,,,str s=g.CellGet(row 0)
,,,,,if s.begi(gg)
,,,,,,int rs=g.RowSelectedGet
,,,,,,if(rs>ln)
,,,,,,,g.RowSelect(-1)
,,,,,,,rs=g.RowSelectedGet
,,,,,,,row=-1
,,,,,,if(row<=ln+1 and row>rs)
,,,,,,,g.RowSelect(row)
,,,,,,,break
,,,,,,if(row = rs and row >= ln)
,,,,,,,g.RowSelect(-1)
,,,,,,,row=-1
,,,if dc=1
,,,,DT_EndDialog(hDlg ln)

#sub CheckForUnique
function ~text keys &ln

int count
for _i 0 numlines(text)
,_s.getl(text _i)
,if(_s[0] = keys)
,,ln=_i
,,count+1
ret count

#sub FlashCodeLine
function curPos iid [hce]
if(!hce) hce=GetQmCodeEditor
mac+ iid
act hce
SendMessage hce SCI.SCI_GOTOPOS curPos 0
int indicator=19
SendMessage(hce SCI.SCI_SETINDICATORCURRENT indicator 0)
SendMessage(hce SCI.SCI_INDICSETALPHA indicator 100)
SendMessage(hce SCI.SCI_INDICSETFORE indicator 0x00FF00)
SendMessage(hce SCI.SCI_INDICSETSTYLE indicator SCI.INDIC_STRAIGHTBOX)
SendMessage(hce SCI.SCI_INDICSETUNDER indicator TRUE)
int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0)
int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0)
act hce
rep 4
,SendMessage(hce SCI.SCI_INDICATORFILLRANGE curPos lep-curPos)
,0.25
,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE curPos lep-curPos)
,0.25
SendMessage(hce SCI.SCI_SETINDICATORCURRENT 0 0)

#sub CloseMenu
int w=wait(0 WV win("" "#32768"))
clo w
#37
kevin, thank you so much!
worked well!


Forum Jump:


Users browsing this thread: 4 Guest(s)