Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamically create SysListView
#21
Function DynamicLV
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 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 "Dialog"
;3 SysListView32 0x5403C04D 0x204 0 0 184 108 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""

int iii= ShowDialog(dd &sub.DlgProc 0)
ret iii

#sub DlgProc v
function# hDlg message wParam lParam

int hsys32=id(3 hDlg)
sel message
,case WM_INITDIALOG
,__Font- f.CreateNew(hsys32 "Microsoft YaHei Mono" 11) ;;change this
,f.SetDialogFont(hDlg "3")
,int es=LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES
,SendMessage hsys32 LVM_SETEXTENDEDLISTVIEWSTYLE es es
,TO_LvAddCol hsys32 0 "" -90
,TO_LvAddCol hsys32 1 "" -10
;,Fill-in values to sys32
,int n=numlines(text)
,for int'i 0 n
,,_s.getl(text i)
,,TO_LvAdd hsys32 i 0 0 _s i+1
,RECT r.left=LVIR_BOUNDS; SendMessage(hsys32 LVM_GETITEMRECT 0 &r)
,int xy=SendMessage(hsys32 LVM_APPROXIMATEVIEWRECT n -1|-1)
,int width = xy & 0x0000FFFF
,int hh = xy>>16&0x0000FFFF
,siz width+4 hh hsys32
,siz width+11 hh-r.bottom+8 hDlg
,sub.LvSelect hsys32 0
,if(isCaret > 0) ;; if caret is found  and flag is 1 move dialog to caret
,,mov xx yy+25 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);;;return this to know dialog was closed  using alt+F4 or esc
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3
,sel nh.code
,,case LVN_KEYDOWN
,,NMLVKEYDOWN* lvk=+nh
,,if lvk.wVKey=188 or lvk.wVKey=190 or lvk.wVKey=191
,,,if lvk.wVKey=188
,,,,sub.SendKey(nh.hwndFrom VK_DOWN)
,,,,ret
,,,if lvk.wVKey=190
,,,,sub.SendKey(nh.hwndFrom VK_UP)
,,,,ret
,,,if lvk.wVKey=191
,,,,DT_EndDialog(hDlg 1000)
,,for i 0 numlines(text)
,,,_s.getl(text i)
,,,if(_s[0] = lvk.wVKey)
,,,,DT_EndDialog(hDlg i)
,,,,break
,,case NM_DBLCLK;;on double left click of listview item
,,i=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
,,DT_EndDialog(hDlg i)
,,case NM_RCLICK;;on right click of listview item
,,i=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
,,str lviText.getl(text i)
,,DT_EndDialog(hDlg 1000)
,,int posF=find(ss lviText 0)
,,sub.FlashCodeLine(posF iid)
#sub LvSelect
function hlv item [flags] ;;flags: 1 don't deselect previous, 2 don't set focus, 4 ensure visible, 8 deselect

;Selects listview item.
;To select none, use item -1.
;To select all, use item -1 and flag 8.
;Note that listview controls with LVS_SINGLESEL style can have max 1 item selected.

LVITEMW li.stateMask=LVIS_FOCUSED|LVIS_SELECTED
if(item>=0)
,if(flags&9=0) SendMessage hlv LVM_SETITEMSTATE -1 &li
,if(flags&8=0) li.state=LVIS_SELECTED; if(flags&2=0) li.state|LVIS_FOCUSED
,SendMessage hlv LVM_SETITEMSTATE item &li
,if(flags&4) SendMessage hlv LVM_ENSUREVISIBLE item 0
else
,if(flags&8) li.state=LVIS_SELECTED
,SendMessage hlv LVM_SETITEMSTATE -1 &li
,
#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 SendKey
function hwnd vk [flags] ;;flags: 0 down-up, 1 down, 2 up

;Posts keyboard messages directly to a control. The window can be inactive.
;You can find virtual-key codes in QM help. For alphanumeric keys, use uppercase characters in '', eg 'A'.

;hwnd - control handle.
;vk - virtual-key code.

int m1 m2 lp=MapVirtualKey(vk 0)<<16|1
sel(vk) case [3,33,34,35,36,37,38,39,40,44,45,46,91,92,93,111,144,VK_RCONTROL,VK_RMENU] lp|0x1000000 ;;ek
if(flags&3!2) PostMessage hwnd WM_KEYDOWN vk lp
if(flags&3!1) PostMessage hwnd WM_KEYUP vk lp|0xC0000000


Messages In This Thread
Dynamically create SysListView - by Davider - 08-18-2022, 03:15 AM
RE: Dynamically create SysListView - by Davider - 08-18-2022, 09:05 AM
RE: Dynamically create SysListView - by Gintaras - 08-18-2022, 09:19 AM
RE: Dynamically create SysListView - by Kevin - 08-19-2022, 11:31 PM
RE: Dynamically create SysListView - by Davider - 08-20-2022, 12:49 AM
RE: Dynamically create SysListView - by Kevin - 08-20-2022, 03:44 AM
RE: Dynamically create SysListView - by Davider - 08-20-2022, 10:28 AM
RE: Dynamically create SysListView - by Kevin - 08-20-2022, 11:51 AM
RE: Dynamically create SysListView - by Davider - 08-20-2022, 12:10 PM
RE: Dynamically create SysListView - by Davider - 08-20-2022, 11:13 PM
RE: Dynamically create SysListView - by Gintaras - 08-21-2022, 11:35 AM
RE: Dynamically create SysListView - by Davider - 08-21-2022, 12:41 PM
RE: Dynamically create SysListView - by Davider - 08-21-2022, 09:41 PM
RE: Dynamically create SysListView - by Gintaras - 08-22-2022, 11:45 AM
RE: Dynamically create SysListView - by Davider - 08-22-2022, 12:42 PM
RE: Dynamically create SysListView - by Gintaras - 08-22-2022, 01:11 PM
RE: Dynamically create SysListView - by Davider - 08-22-2022, 02:08 PM
RE: Dynamically create SysListView - by Kevin - 08-23-2022, 03:30 AM
RE: Dynamically create SysListView - by Davider - 08-23-2022, 09:40 AM
RE: Dynamically create SysListView - by Davider - 11-04-2022, 02:05 AM
RE: Dynamically create SysListView - by Kevin - 11-04-2022, 05:31 AM
RE: Dynamically create SysListView - by Davider - 11-04-2022, 05:57 AM
RE: Dynamically create SysListView - by Kevin - 11-04-2022, 02:45 PM
RE: Dynamically create SysListView - by Davider - 11-07-2022, 12:19 PM
RE: Dynamically create SysListView - by Kevin - 11-17-2022, 01:37 AM
RE: Dynamically create SysListView - by Davider - 11-25-2022, 04:34 AM
RE: Dynamically create SysListView - by Kevin - 11-27-2022, 02:19 AM
RE: Dynamically create SysListView - by Davider - 11-27-2022, 02:44 AM
RE: Dynamically create SysListView - by Davider - 12-02-2022, 02:24 AM
RE: Dynamically create SysListView - by Davider - 12-02-2022, 12:31 PM
RE: Dynamically create SysListView - by Kevin - 12-02-2022, 05:42 PM
RE: Dynamically create SysListView - by Davider - 12-02-2022, 09:14 PM
RE: Dynamically create SysListView - by Kevin - 12-10-2022, 03:09 AM
RE: Dynamically create SysListView - by Davider - 12-10-2022, 10:47 PM
RE: Dynamically create SysListView - by Davider - 03-26-2023, 02:16 AM
RE: Dynamically create SysListView - by Kevin - 03-27-2023, 01:29 AM
RE: Dynamically create SysListView - by Davider - 03-27-2023, 02:26 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)