Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamically create SysListView
#1
Hi,

I created a function DynamicLV, I want to create SysListView dynamically
At present, some features have been implemented, but there are still some problems below:

 1. Line 37: The font settings are not in effect 
 2. How to implement: After the dialog box pops up, the first line of text is selected by default
 3. How to implement: After pressing the letter that begins with a line, close the dialog box and output the index of the selected line
 4. How to implement: Do not display the header row where Lable is located
 5. How to implement: Display separator lines between lines of text
 6. How to implement: The height of the dialog box automatically adapts to the number of lines of text

Most of the code comes from the forum, with some modifications, There may be an easier way to implement it, 

Thanks in advance for any advice and help
david

The final result I'm looking forward to is as follows

[Image: abc.png]

Macro Macro4
Trigger Aq     Help - how to add the trigger to the macro
Code:
Copy      Help
_s=
;A I'm in the line 1
;B I'm in the line 2
;C I'm in the line 3
;D I'm in the line 4
;E I'm in the line 5

_i=DynamicLV(_s)

mes _i

----------------------------------------------------------------------------------------------------------------------------------------
Function DynamicLV
Code:
Copy      Help
function# str'text
out
;https://www.quickmacros.com/forum/showthread.php?tid=5936&pid=28797#pid28797
str dd=
;BEGIN DIALOG
;0 "" 0x90080AC8 0x0 0 0 184 108 "Dialog"
;3 SysListView32 0x5403804D 0x204 0 0 184 108 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc v
function# hDlg message wParam lParam

int hsys32=id(3 hDlg)
sel message
,case WM_INITDIALOG

,SendMessage hsys32 LVM_SETIMAGELIST LVSIL_SMALL 0
,
,int es=LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_SUBITEMIMAGES
,SendMessage hsys32 LVM_SETEXTENDEDLISTVIEWSTYLE es es
,sub.LvAddCol hsys32 0 "Label" -90
,sub.LvAddCol hsys32 1 "ID" -10

;,Fill-in values to sys32
,SendMessage hsys32 LVM_DELETEALLITEMS 0 0
,str col0=text

,int n=numlines(col0)
,for int'i 0 n
,,_s.getl(col0 i)
,,sub.LvAdd hsys32 i 0 0 _s i+1
,
,__Font f.CreateNew(hsys32 "Microsoft YaHei Mono" 11) ;;change this
,SendMessage hsys32 WM_SETFONT f 1
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
NMITEMACTIVATE* na=+nh
int j
sel nh.code
,case LVN_ITEMCHANGED
,if(na.uNewState&LVIS_SELECTED and na.uOldState&LVIS_SELECTED=0) ;;listview item selected
,,sel nh.idFrom
,,,case 3
,,,j=na.iItem;; if(j<0 or j>=aFiles.len) ret
,,,out j
ret j
,,,
#sub LvAddCol
function hlv index $txt width

;Adds column to SysListView32 control that has LVS_REPORT style (1).
;Index of first colunm is 0. If index <0, adds to the end.
;If width <0, it is interpreted as -percentage.

LVCOLUMNW col.mask=LVCF_WIDTH|LVCF_TEXT
col.pszText=@txt
if(width<0) RECT r; GetClientRect hlv &r; width=-width*r.right/100
col.cx=width
if(index<0) index=0x7fffffff
SendMessage hlv LVM_INSERTCOLUMNW index &col

#sub LvAdd
function# hlv index lparam image ~s [~s1] [~s2] [~s3] [~s4] [~s5] [~s6] [~s7] [~s8] [~s9]

;Adds item to SysListView32 control that has LVS_REPORT style and 1 to 10 columns.

if(index<0) index=0x7FFFFFFF
LVITEMW lvi.mask=LVIF_TEXT|LVIF_PARAM|LVIF_IMAGE
lvi.iItem=index
lvi.pszText=@s
lvi.lParam=lparam
lvi.iImage=image
index=SendMessage(hlv LVM_INSERTITEMW 0 &lvi)

if index>=0
,int i; str* p=&s
,for i 1 getopt(nargs)-4
,,lvi.iItem=index
,,lvi.iSubItem=i
,,lvi.pszText=@p[i]
,,SendMessage(hlv LVM_SETITEMTEXTW index &lvi)
ret index


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: 4 Guest(s)