Posts: 1,027
Threads: 245
Joined: Jul 2022
08-18-2022, 03:15 AM
(This post was last modified: 08-18-2022, 03:19 AM by Davider.)
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
Macro Macro4
Trigger Aq
_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
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
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-18-2022, 09:05 AM
(This post was last modified: 08-18-2022, 09:08 AM by Davider.)
How to see the function definition of the QM AutoText list QM_PopupList(I wanted a feature similar to it), I did not find it in the QM system folder
Posts: 12,061
Threads: 140
Joined: Dec 2002
Posts: 1,335
Threads: 61
Joined: Jul 2006
try this should cover all 6 requests
added additional functionality
enter key also returns selected item idex
double left mouse click on item also does the same
Function DynamicLV
;/
function# str'text
out
str dd=
F
;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
,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 0)
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3
,sel nh.code
,,case LVN_KEYDOWN
,,NMLVKEYDOWN* lvk=+nh
,,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
,,;lvSelect
,,i=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
,,DT_EndDialog(hDlg i)
#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
added functionality if alt+f4 is used to close dialog macro will end
Macro Macro9
_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
int i=DynamicLV(_s)
if i=1000
,ret;; end if alt+f4 was used to closed dialog
out i
str ss
ss.getl(_s i)
out ss
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-20-2022, 12:49 AM
(This post was last modified: 08-20-2022, 03:22 AM by Davider.)
@ Kevin
Thanks for your help,
Worked well,
How to achieve?
1.When I press the esc key, close the dialog directly, do not output( Don't do anything)
2.make the dialog appear below the input cursor,e.g:
DynamicLV(_s) ;; Appears at the input cursor, If the input cursor is not found, Appears in the center of the screen
DynamicLV(_s 0) ;; Appears in the center of the screen
DynamicLV(_s 1) ;;A ppears at the input cursor
My intention is to use it in the AutoText, like the below
I also want to implement that:
when I press the right mouse button on any item in this DynamicLV dialog,
then the dialog closes and then navigates to the subfunction where the dialog is located, e.g: sub.Sub1 , This way I can easily edit it, Is this possible?
Autotext autotext8
Trigger $t
/b/i/c/m
te :sub.Sub1 ;;1 test DynamicLV
te :sub.Sub2 ;;2 test
#sub Sub1 m
_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
;F I'm in the line 6
_i=DynamicLV(_s)
sel _i+1
,case 1
,mes "I'm in the line 1"
,case 2
,mes "I'm in the line 2"
,case 3
,mes "I'm in the line 3"
,case 4
,mes "I'm in the line 4"
,case 5
,mes "I'm in the line 5"
,case 6
,mes "I'm in the line 6"
#sub Sub2 m
mes "hello world"
Posts: 1,335
Threads: 61
Joined: Jul 2006
somehow the cancel part got messed up
for #1
change
,case IDCANCEL
,DT_EndDialog(hDlg 0)
to
,case IDCANCEL
,DT_EndDialog(hDlg 1000)
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-20-2022, 10:28 AM
(This post was last modified: 08-20-2022, 10:38 AM by Davider.)
for #2
--------------------------------------------------
function# str'text
int x y
GetCaretXY x y
--------------------------------------------------
case WM_INITDIALOG
mov x y+20 hDlg
--------------------------------------------------
How to achieve?
If the input cursor is not found, Appears in the center of the screen, Using the above code, the dialog appears in the upper-left corner of the screen
DynamicLV(_s 0) ;;Appears in the center of the screen
DynamicLV(_s 1) ;;Appears at the input cursor
Posts: 1,335
Threads: 61
Joined: Jul 2006
you almost have it
just need a couple more things
Function DynamicLV
;/
function# str'text [flags];;optional .1 show dialog at caret position if possible. 0 or omitted show dialog at center of screen(default)
out
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
,,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)
#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
calling examples
int i=DynamicLV(_s);;center of screen
int i=DynamicLV(_s 1);;below cursor
Posts: 1,027
Threads: 245
Joined: Jul 2022
@ Kevin
Thanks again, works well, nice features and cases
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-20-2022, 11:13 PM
(This post was last modified: 08-20-2022, 11:58 PM by Davider.)
@Kevin
About:
when I press the right mouse button on any item in this DynamicLV dialog,
then the dialog closes and then navigates to the subfunction where the dialog is located, e.g: sub.Sub1 , This way I can easily edit it
I think it's possible, see the picture below
When the DynamicLV dialog is displayed, it will display the name of the autotext file being operated in the Running items toolbar of the QM
So, get it -> open it -> search the file for right-click item's text, e.g: A I'm in the line 1 -> Highlight it
This requires more programming skills
Some code I found:
Macro Macro6
;Display all threads
int i n=EnumQmThreads(0 0 0 0)
ARRAY(QMTHREAD) a.create(n)
for i 0 EnumQmThreads(&a[0] n 0 0)
,out _s.getmacro(a[i].qmitemid 1)
;Open the autotext file
mac+ "autotext8"
Posts: 12,061
Threads: 140
Joined: Dec 2002
Maybe this can help.
Macro Macro3229
;Assume you want to add items to some list, menu, etc and implement a "go to source code" command.
;For it use function Statement in the function that adds a single item.
;This is a simplest example.
sub.Add("one")
1
sub.Add("two")
#sub Add
function $text
;get caller's QM item id and position in source code
int iid pos=Statement(1 0 0 iid)
;go to source code now
mac+ iid
int h=GetQmCodeEditor
act h
SendMessage h SCI.SCI_GOTOPOS pos 0
;Normally you would add iid/pos to an array and go to source code later on user request etc.
;Create a class. Let Add be a function of that class. Let the array be a class field (variable).
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-21-2022, 12:41 PM
(This post was last modified: 08-21-2022, 12:54 PM by Davider.)
I defined it as a function WAI
Then called in a subfunction of the AutoText item,
But it will always execute
Also, I didn't find the event settings on the item by mouse Right-click
It would be much better if the operation on WAI was defined as an argument in the DynamicLV function, e.g: DynamicLV(_s 1 1) ;;set 1 can locate by right-clicking
Autotext autotext8
Trigger $t
/b/i/c/m
te :sub.Sub1 ;;1 test DynamicLV
#sub Sub1 m
WAI "a"
_s=
;A I'm in the line 1
;B I'm in the line 2
;C I'm in the line 3
_i=DynamicLV(_s)
sel _i+1
,case 1
,mes "I'm in the line 1"
,case 2
,mes "I'm in the line 2"
,case 3
,mes "I'm in the line 3"
,case 4
,mes "I'm in the line 4"
,case 5
,mes "I'm in the line 5"
,case 6
,mes "I'm in the line 6"
Function WAI
function $text ;;Where Am I
;get caller's QM item id and position in source code
int iid pos=Statement(1 0 0 iid)
;go to source code now
mac+ iid
int h=GetQmCodeEditor
act h
SendMessage h SCI.SCI_GOTOPOS pos 0
;Normally you would add iid/pos to an array and go to source code later on user request etc.
;Create a class. Let Add be a function of that class. Let the array be a class field (variable).
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-21-2022, 09:41 PM
(This post was last modified: 08-22-2022, 03:10 AM by Davider.)
Now, Use the following code, I can open the aototext file where this item is located by right-clicking.
However, there is no implementation of positioning to the subfunction, how to Search for item text in the QM Code Editor
e.g: search A I'm in the line 1 Note: There is a space in front
-------------------------------------------------------------------------------------------------
messages3 add:
case NM_RCLICK ;;on right click of listview item
i=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
str ss.getl(text i)
out ss
DT_EndDialog hDlg 1000
n=EnumQmThreads(0 0 0 0)
ARRAY(QMTHREAD) a.create(n)
for _i 0 EnumQmThreads(&a[0] n 0 0)
_s.getmacro(a[_i].qmitemid 1)
mac+ _s
Todo:
1.In the QM Editor, search for the text of the right-clicked item
2.Highlight flashes to show it
about:
_s.getmacro(a[_i].qmitemid 1)
Because it is possible that other functions will also running, Which number should I set? 34?
--------------------------------------------------------------------------------------------------------
getmacro([$macro|iid] [what]) ;;`Gets macro text, name, etc.` what: 0 text, 1 name, 2 trigger.
Obsolete what: 3 type ("0" macro, "1" function, "2" menu, "3" toolbar, "4" autotext, "5" folder, "6" member, "7" file link), 4 disabled, 5 encrypted, 6 shared, 7 id, 8 read-only.
Posts: 12,061
Threads: 140
Joined: Dec 2002
08-22-2022, 11:45 AM
(This post was last modified: 08-22-2022, 11:52 AM by Gintaras.)
Don't use EnumQmThreads. Use Statement at the start of the function (see my previous post). Get caller's text with _s.getmacro(iid), and parse that text.
To highlight, use SendMessage(GetQmCodeEditor SCI.XXX ...) where XXX is a Scintilla message documented in the Scintilla website. I don't remember what message to use.
Posts: 1,027
Threads: 245
Joined: Jul 2022
08-22-2022, 12:42 PM
(This post was last modified: 08-22-2022, 12:44 PM by Davider.)
Thanks for the explanation,
sorry, I don't quite understand how to use Statement in the AutoText subfunction
about highlight , I found a piece of code in the forum
------------------------------------------------------------------------
#sub FlashCodeLine
function curPos hce
if(!hce) hce=GetQmCodeEditor
int indicator=9
int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0)
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 lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0)
int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0)
rep 4
SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp)
0.25
SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp)
0.25
SendMessage(hce SCI.SCI_SETINDICATORCURRENT 0 0)
Posts: 12,061
Threads: 140
Joined: Dec 2002
Function DynamicLV
;/
function str'items
int iid to=Statement(1 0 0 iid)
str s.getmacro(iid)
s.left(s to)
out s
;Then on right-click parse s to get item text position in s. Then mac+ iid, SCI_GOTOPOS, etc, like in my previous post.
Posts: 1,027
Threads: 245
Joined: Jul 2022
I still don't quite understand how to use the above Function,
Below is the complete sample code, with two features not implemented and a note after the code
Autotext autotext8
Trigger $t
/b/i/c/m
te :sub.Sub1 ;;1 test DynamicLV
#sub Sub1 m
_s=
;A I'm in the line 1
;B I'm in the line 2
;C I'm in the line 3
_i=DynamicLV(_s 1)
sel _i+1
,case 1
,mes "I'm in the line 1"
,case 2
,mes "I'm in the line 2"
,case 3
,mes "I'm in the line 3"
,case 4
,mes "I'm in the line 4"
,case 5
,mes "I'm in the line 5"
,case 6
,mes "I'm in the line 6"
Function DynamicLV
;/
function# str'text [flags];;optional .1 show dialog at caret position if possible. 0 or omitted show dialog at center of screen(default)
out
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
,,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)
,,out i
,,case NM_RCLICK ;;____________________________________________________________right-click listview item,Save the text to ss
,,i=SendDlgItemMessage(hDlg 3 LVM_GETNEXTITEM -1 LVNI_SELECTED)
,,str ss.getl(text i)
,,out ss
,,DT_EndDialog hDlg 1000
,,n=EnumQmThreads(0 0 0 0) ;;__________________________________________________Todo1: use EnumQmThreads open autotext item
,,ARRAY(QMTHREAD) a.create(n)
,,for _i 0 EnumQmThreads(&a[0] n 0 0)
,,,_s.getmacro(a[_i].qmitemid 1)
,,mac+ _s
,,
,,;;;__________________________________________________________________________Todo2: Navigate to the Line where ss is located
,,
,,;sub.FlashCodeLine curPos hce ;;_____________________________________________FlashCodeLine ss line
#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 hce
if(!hce) hce=GetQmCodeEditor
int indicator=9
int line=SendMessage(hce SCI.SCI_LINEFROMPOSITION curPos 0)
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 lsp=SendMessage(hce SCI.SCI_POSITIONFROMLINE line 0)
int lep=SendMessage(hce SCI.SCI_GETLINEENDPOSITION line 0)
rep 4
;;;;SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp)
;;;;0.25
;;;;SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp)
;;;;0.25
SendMessage(hce SCI.SCI_SETINDICATORCURRENT 0 0)
Posts: 1,335
Threads: 61
Joined: Jul 2006
this covers it
Autotext Autotext8
Trigger $t
/b/i/c/m
te :sub.Sub1 ;;1 test DynamicLV
te :sub.Sub2 ;;2 test
#sub Sub1 m
_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
;F I'm in the line 6
_i=DynamicLV(_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
#sub Sub2 m
mes "hello world"
Function DynamicLV
;/
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
,,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)
,,out lviText
,,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)
Posts: 1,027
Threads: 245
Joined: Jul 2022
@ Kevin
wow! thank you!!
All the features have been implemented and work well!
Posts: 1,027
Threads: 245
Joined: Jul 2022
11-04-2022, 02:05 AM
(This post was last modified: 11-04-2022, 02:42 AM by Davider.)
I want to use , and . to select an item, use / close, but it has no effect
,case WM_CHAR
,sel(wParam)
,,case 44 ;;Press ,
,,key D
,,ret
,,case 46 ;;Press .
,,key U
,,ret
,,case 47 ;;Press / close
,,clo
,,ret
Posts: 1,335
Threads: 61
Joined: Jul 2006
Function DynamicLV
;/
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
Posts: 1,027
Threads: 245
Joined: Jul 2022
11-04-2022, 05:57 AM
(This post was last modified: 11-04-2022, 08:25 AM by Davider.)
Press the key , . an alert sound will be emitted, Using the up and down keys directly will not
addition, I want to press the Tab key, which can confirm the selection
Posts: 1,335
Threads: 61
Joined: Jul 2006
sorry i had sounds off didn't catch it. Will need to eat those keys so probably best to use this
Function DynamicLVKeys
Trigger !v"Dialog_DLV" "#32770"
int hwnd=TriggerWindow
int- hlv=child("" "SysListView32" hwnd)
int hh=SetWindowsHookEx(WH_KEYBOARD_LL &sub.Hook_WH_KEYBOARD_LL _hinst 0)
opt waitmsg 1
rep
,0.2 -WV hlv
,err
,,continue
,break
UnhookWindowsHookEx hh
#sub Hook_WH_KEYBOARD_LL
function# nCode message KBDLLHOOKSTRUCT&k
if(nCode<0) goto gNext
int- hlv
int isActive=hlv
if(!isActive) SendMessage hlv WM_ACTIVATE WA_ACTIVE 0
int up=k.flags&LLKHF_UP
FormatKeyString k.vkCode 0 &_s;
if _s=","
,if(!up)
,,SendKeysToWindow2(hlv key(D))
,ret 1
if _s="."
,if(!up)
,,SendKeysToWindow2(hlv key(U))
,ret 1
if _s="/"
,if(!up)
,,SendKeysToWindow2(hlv key(Z))
,ret 1
if _s="Tab"
,,if(!up)
,,,SendKeysToWindow2(hlv key(Y))
,,ret 1
;gNext
ret CallNextHookEx(0 nCode message &k)
Function DynamicLV
;/
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_DLV"
;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
,,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)
Posts: 1,027
Threads: 245
Joined: Jul 2022
11-07-2022, 12:19 PM
(This post was last modified: 11-07-2022, 11:51 PM by Davider.)
thanks, the code Works well!
But there is one place where it is not perfect, such as the following example:
There are two lines that begin with the letter B
When I press the B key, only the first item is output directly
So, I want to pick the first item that starts with the letter B, Press the B key again to move to the second item, At this point, I can also use , and . Select them
But, If the letter at the begin of a line is unique, when I press the letter, the item is output directly, such as the A, C, E in the example
This can be a bit complicated to implement
Autotext Autotext
Trigger $t
/b/i/c/m
te :sub.Sub1 ;;1 test DynamicLV
#sub Sub1 m
_s=
;A I'm in the line A
;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=DynamicLV(_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
Posts: 1,335
Threads: 61
Joined: Jul 2006
11-17-2022, 01:37 AM
(This post was last modified: 11-17-2022, 01:41 AM by Kevin.)
this covers that
Function DynamicLV
;/
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 ""
;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 "Segoe UI" 12) ;;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<64 or lvk.wVKey>91)
,,,ret
,,int ln dc=sub.CheckForUnique(text lvk.wVKey ln)
,,if dc=0
,,,DT_EndDialog(hDlg ln)
,,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 lviText2
,,GetListViewItemText nh.hwndFrom i-1 lviText2 0 2
,,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 CheckForUnique
function ~text keys &ln
int count
for _i 0 numlines(text)
,_s.getl(text _i)
,if(_s[0] = keys)
,,ln=_i
,,count+1
if(count >1) ret 1; else ret
Posts: 1,027
Threads: 245
Joined: Jul 2022
11-25-2022, 04:34 AM
(This post was last modified: 11-25-2022, 01:30 PM by Davider.)
@ Kevin
I want the DynamicLV window to be centered relative to the currently open window, When the text cursor cannot be found, such as in PowerShell ISE
I have the code below, but it doesn't work
Macro Macro3
int w=win("" "#32770")
RECT r; DpiGetWindowRect w &r
int wL=hwnd
int cx cy
GetWinXY wL 0 0 cx cy
int x = r.left + ((r.right - r.left - cx)/2)
int y = r.top + ((r.bottom - r.top - cy)/2)
mov x y wL
Posts: 1,335
Threads: 61
Joined: Jul 2006
before
int iid to=Statement(1 0 0 iid)
add
int w1=win()
RECT r1; DpiGetWindowRect w1 &r1
after
,if(isCaret > 0) ;; if caret is found and flag is 1 move dialog to caret
,,mov xx yy+25 hDlg
add
,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
Posts: 1,027
Threads: 245
Joined: Jul 2022
@ Kevin
worked well, Thank you
Posts: 1,027
Threads: 245
Joined: Jul 2022
12-02-2022, 02:24 AM
(This post was last modified: 12-02-2022, 03:01 AM by Davider.)
@ Kevin
Switching from F to D sometimes does not respond and requires waiting a while
Not sensitive enough
Autotext AT1
Trigger $t
/b/i/c/m
te :sub.Sub1 ;;1 test DynamicLV
#sub Sub1 m
_s=
;A I'm in the line A
;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=DynamicLV(_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
Posts: 1,027
Threads: 245
Joined: Jul 2022
This feature is useful and can be used for classification
|