Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to execute QM item in dialog
#1
hello, I created a function that can display a list of QM items in a combo box, Macros, functions, autotext and item are grouped, Please see the picture below, but I don't know how to execute item in it.

I need to implement the following features:

1. After selecting the item, double click or enter, can execute it

2. After selecting the item, right click to edit it

3. After selecting the item, press the esc key to cancel the selection and position the cursor in the edit box where it is located, waiting for input.

4. Press the esc key twice to close the dialog box.

If there are too many hotkeys defined, it is not easy to remember. Executing with the above method is sometimes convenient.
Idea

Any suggestions are welcome, thanks in advance Heart


Macro QM_item_manage
Code:
Copy      Help
out

QMITEM qmac; int imac
ARRAY(str) amac
rep
,imac=qmitem(-imac 2 &qmac 1)
,if(imac=0) break
,if qmac.itype=0
,,amac[]=qmac.name
,,
,,
QMITEM qfun; int ifun
ARRAY(str) afun
rep
,ifun=qmitem(-ifun 2 &qfun 1)
,if(ifun=0) break
,if qfun.itype=1
,,afun[]=qfun.name
,,
,,
QMITEM qaut; int iaut
ARRAY(str) aaut
rep
,iaut=qmitem(-iaut 2 &qaut 1)
,if(iaut=0) break
,if qaut.itype=4
,,aaut[]=qaut.name

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 426 204 "QM_item_manage"
;3 ComboBox 0x54230641 0x0 8 24 98 172 "Mac"
;5 Static 0x54000000 0x0 44 8 48 12 "Macro"
;4 ComboBox 0x54230641 0x4 112 24 98 172 "Fun"
;6 ComboBox 0x54230641 0x4 216 24 98 172 "Auto"
;7 ComboBox 0x54230641 0x4 320 24 98 172 "item"
;8 Static 0x54000000 0x0 145 8 48 12 "Function"
;9 Static 0x54000000 0x0 249 8 48 12 "Autotext"
;10 Static 0x54000000 0x0 361 8 48 12 "Item"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 6 7"
str cb3Mac cb4Fun cb6Aut cb7ite
cb3Mac=amac
cb4Fun=afun
cb6Aut=aaut

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


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,;CB_SelectString(id(3 hDlg) "test")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
int hcb2=id(7 hDlg) ;;combo box
sel wParam
,case IDOK
,case IDCANCEL
,
,case CBN_SELENDOK<<16|6
,str cb1si
,_i=CB_SelectedItem(lParam cb1si)
,str cb2ii itemscb2=sub.gotoitemedit(cb1si)
,SendMessage(hcb2 CB_RESETCONTENT 0 0)
,itemscb2.findreplace(":sub." "     ")
,itemscb2.findreplace(";;" "     ")
,foreach cb2ii itemscb2
,,CB_Add(hcb2 cb2ii)
,
,case CBN_DBLCLK<<16|7
,str cb2t
,_i=CB_SelectedItem(lParam cb2t)
,_s.getwintext(id(6 hDlg))
,mac+ _s
,int c=GetQmCodeEditor
,SendMessage(c SCI.SCI_GOTOLINE _i+1 0)
,int ii=findrx(cb2t "Sub." 0 1)
,int cp=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
,cp+ii
,SendMessage(c SCI.SCI_GOTOPOS cp 0)
,
,SendMessage(c SCI.SCI_SETSELBACK 0 0x00FF00)
,'SE

ret 1


#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim


Attached Files Image(s)
   
#2
All features have been completed,  Smile

My programming level is limited, only for the time being. I hope someone can suggest some improvements, thank you very much. Heart




Function Macro10
Code:
Copy      Help
out

QMITEM qmac; int imac
ARRAY(str) amac
rep
,imac=qmitem(-imac 2 &qmac 1)
,if(imac=0) break
,if qmac.itype=0
,,amac[]=qmac.name
,,
,,
QMITEM qfun; int ifun
ARRAY(str) afun
rep
,ifun=qmitem(-ifun 2 &qfun 1)
,if(ifun=0) break
,if qfun.itype=1
,,afun[]=qfun.name
,,
,,
QMITEM qaut; int iaut
ARRAY(str) aaut
rep
,iaut=qmitem(-iaut 2 &qaut 1)
,if(iaut=0) break
,if qaut.itype=4
,,aaut[]=qaut.name

str iamac=amac
str iafun=afun
str iaaut=aaut

str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 409 163 "Dialog"
;3 Edit 0x54030080 0x200 5 22 96 14 ""
;7 Edit 0x54030080 0x204 106 22 96 14 ""
;8 Edit 0x54030080 0x204 207 22 96 14 ""
;9 Edit 0x54030080 0x204 308 22 96 14 ""
;4 ListBox 0x54230101 0x200 5 37 96 120 "" "Double click Run the Macro[]Right click Open the Macro"
;10 ListBox 0x54230101 0x204 106 37 96 120 "" "Double click Run the Funtion[]Right click Open the Funtion"
;11 ListBox 0x54230101 0x204 207 37 96 120 "" "Double click Open the AutoText"
;12 ListBox 0x54230101 0x204 308 37 96 120 "" "Double click Open the AutoText item"
;6 Static 0x54000000 0x0 37 8 48 12 "Macro"
;13 Static 0x54000000 0x0 133 8 48 12 "Function"
;14 Static 0x54000000 0x0 238 8 48 12 "Autotext"
;15 Static 0x54000000 0x0 333 8 48 12 "AutoText item"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 7 8 9 4 10 11 12"
str e3 e7 e8 e9 lb4 lb10 lb11 lb12

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


#sub DlgProc v
function# hDlg message wParam lParam

;messages
sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Search Macro"
,SendMessage id(7 hDlg) EM_SETCUEBANNER TRUE @"Search Function"
,SendMessage id(8 hDlg) EM_SETCUEBANNER TRUE @"Search AutoText"
,SendMessage id(9 hDlg) EM_SETCUEBANNER TRUE @"Search AutoText item"
,
,SetTimer hDlg 1 10 0
,int he8=id(8 hDlg)
,SetProp he8 "wndproc" SubclassWindow(he8 &sub.EditSubclassProc8)

,
,;SetTimer hDlg 4 10 0
,;int he9=id(9 hDlg)
,;SetProp he9 "wndproc" SubclassWindow(he9 &sub.EditSubclassProc)
,
,SetTimer hDlg 2 10 0
,int he3=id(3 hDlg)
,SetProp he3 "wndproc" SubclassWindow(he3 &sub.EditSubclassProc3)
,
,SetTimer hDlg 3 10 0
,int he7=id(7 hDlg)
,SetProp he7 "wndproc" SubclassWindow(he7 &sub.EditSubclassProc7)
,
,case WM_DESTROY
,
,case WM_COMMAND goto messages2
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hDlg wParam
,,goto giaaut
,,
,,;case 4
,,;KillTimer hDlg wParam
,,;goto giaati
,,
,,case 2
,,KillTimer hDlg wParam
,,goto giamac
,,
,,case 3
,,KillTimer hDlg wParam
,,goto giafun
ret
;messages2

int hlb12=id(12 hDlg) 

sel wParam
,case EN_CHANGE<<16|8
,SetTimer hDlg 1 100 0
,
,;case EN_CHANGE<<16|9
,;SetTimer hDlg 4 100 0
,
,case EN_CHANGE<<16|3
,SetTimer hDlg 2 100 0
,
,case EN_CHANGE<<16|7
,SetTimer hDlg 3 100 0
,
,case LBN_DBLCLK<<16|4
,goto gShowSelected4
,
,case LBN_DBLCLK<<16|10
,goto gShowSelected10
,
,case LBN_DBLCLK<<16|11
,goto gShowSelected11
,
,case LBN_SELCHANGE<<16|11
,str lb11si
,_i=LB_SelectedItem(lParam lb11si)
,str lb12ii itemslb12=sub.gotoitemedit(lb11si)
,SendMessage(hlb12 LB_RESETCONTENT 0 0)
,itemslb12.findreplace(":sub.Sub" "   ")
,itemslb12.findreplace(";;" "   ")
,foreach lb12ii itemslb12
,,LB_Add(hlb12 lb12ii)
,
,case LBN_DBLCLK<<16|12
,str lb12t
,_i=LB_SelectedItem(lParam lb12t)
,LB_SelectedItem id(11 hDlg) _s 
,;mes _s
,mac+ _s
,int c=GetQmCodeEditor
,SendMessage(c SCI.SCI_GOTOLINE _i+1 0)
,int ii=findrx(lb12t "\d" 0 1)
,int cp=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
,cp+ii
,SendMessage(c SCI.SCI_GOTOPOS cp 0)
,
,case IDOK
,case IDCANCEL
ret 1

;giamac
int hlb4=id(4 hDlg)
SendMessage hlb4 LB_RESETCONTENT 0 0
str s4 sEdit4.getwintext(id(3 hDlg)) 
foreach s4 iamac
,if(sEdit4.len and find(s4 sEdit4 0 1)<0) continue
,LB_Add hlb4 s4
ret

;giafun
int hlb10=id(10 hDlg)
SendMessage hlb10 LB_RESETCONTENT 0 0
str s10 sEdit10.getwintext(id(7 hDlg)) 
foreach s10 iafun
,if(sEdit10.len and find(s10 sEdit10 0 1)<0) continue
,LB_Add hlb10 s10
ret

;giaaut
int hlb11=id(11 hDlg)
SendMessage hlb11 LB_RESETCONTENT 0 0
str s11 sEdit11.getwintext(id(8 hDlg)) 
foreach s11 iaaut
,if(sEdit11.len and find(s11 sEdit11 0 1)<0) continue
,LB_Add hlb11 s11
ret

;giaati
;SendMessage hlb12 LB_RESETCONTENT 0 0
;str s12 sEdit12.getwintext(id(9 hDlg))
;ARRAY(str) iaati
;iaati=???
;foreach s12 iaati
,;if(sEdit12.len and find(s12 sEdit11 0 1)<0) continue
,;LB_Add hlb12 s12
;ret

;gShowSelected4
hlb4=id(4 hDlg)
_i=LB_SelectedItem(hlb4)
LB_GetItemText hlb4 _i _s 
mac _s
ret

;gShowSelected10
hlb10=id(10 hDlg)
_i=LB_SelectedItem(hlb10)
LB_GetItemText hlb10 _i _s
mac _s
ret

;gShowSelected11
hlb11=id(11 hDlg)
_i=LB_SelectedItem(hlb11)
LB_GetItemText hlb11 _i _s
mac+ _s
ret

#sub EditSubclassProc3
function# hWnd message wParam lParam

;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,
,case WM_GETDLGCODE
,sel(wParam) 
,,case [VK_RETURN,VK_SPACE]
,,ret DLGC_WANTALLKEYS

,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,SendMessage id(4 GetParent(hWnd)) message wParam lParam
,,ret
,,case [VK_RETURN,VK_SPACE]
,,SendMessage GetParent(hWnd) WM_COMMAND LBN_DBLCLK<<16|4 hWnd
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

#sub EditSubclassProc7
function# hWnd message wParam lParam

;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,
,case WM_GETDLGCODE
,sel(wParam) 
,,case [VK_RETURN,VK_SPACE]
,,ret DLGC_WANTALLKEYS

,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,SendMessage id(10 GetParent(hWnd)) message wParam lParam
,,ret
,,case [VK_RETURN,VK_SPACE]
,,SendMessage GetParent(hWnd) WM_COMMAND LBN_DBLCLK<<16|10 hWnd
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

#sub EditSubclassProc8
function# hWnd message wParam lParam

;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,
,case WM_GETDLGCODE
,sel(wParam) 
,,case [VK_RETURN,VK_SPACE]
,,ret DLGC_WANTALLKEYS

,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,SendMessage id(11 GetParent(hWnd)) message wParam lParam
,,ret
,,case [VK_RETURN,VK_SPACE]
,,SendMessage GetParent(hWnd) WM_COMMAND LBN_DBLCLK<<16|11 hWnd
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim
#3
You made a few mistakes and code can be changed dramatically. will post soon away from pc.
#4
Thanks for your help, I am very curious to know how the code is improved, I am waiting for your release Smile
#5
don't have enough time to post full code but will post a few things that need fixing 
#1 you only need 1 sub.EditSubclassProc function also you need to make sure you remove props when the dialog closes. 
Code:
Copy      Help
,case WM_INITDIALOG
,SetProp id(8 hDlg) "wndproc" SubclassWindow((id(8 hDlg)) &sub.EditSubclassProc) 
,SetProp id(3 hDlg) "wndproc" SubclassWindow((id(3 hDlg)) &sub.EditSubclassProc) 
,SetProp id(7 hDlg) "wndproc" SubclassWindow((id(7 hDlg)) &sub.EditSubclassProc) 
,case WM_DESTROY
,RemoveProp id(8 hDlg) "wndproc" ;;remove prop on dialog close
,RemoveProp id(3 hDlg) "wndproc" ;;remove prop on dialog close
,RemoveProp id(7 hDlg) "wndproc" ;;remove prop on dialog close    
 
Code:
Copy      Help
#sub EditSubclassProc
function# hWnd message wParam lParam
int cid=GetDlgCtrlID(hWnd)
int Phwnd= GetParent(hWnd)
;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,case WM_GETDLGCODE
,sel(wParam) case [VK_RETURN] ret DLGC_WANTALLKEYS    
,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam ;;virtual key code
,,case VK_RETURN
,,;on enter in the edit box select the item in the list box
,,sel cid
,,,case 3
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(4 Phwnd)) id(4 Phwnd)
,,,case 7
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(10 Phwnd)) id(10 Phwnd)
,,,case 8
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(11 Phwnd)) id(11 Phwnd)
,,ret    
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,;relay these keys to the listbox and not to the edit box
,,sel cid
,,,case 3
,,,SendMessage id(4 Phwnd) message wParam lParam            
,,,case 7
,,,SendMessage id(10 Phwnd) message wParam lParam
,,,case 8
,,,SendMessage id(11 Phwnd) message wParam lParam
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

also dont need multiple calls to qmtiem can do all in 1 call. 
Code:
Copy      Help
QMITEM q; int i
ARRAY(str) aaut amac afun
rep
,i=qmitem(-i 2 &q 1)
,if(i=0) break
,sel q.itype
,,case 0
,,amac[]=q.name
,,case 1
,,afun[]=q.name
,,case 4
,,aaut[]=q.name
str iamac=amac
str iafun=afun
str iaaut=aaut

dont need set timer when dialog starts it slows down the display of the lists

load list like this instead
Code:
Copy      Help
str controls = "3 4 7 8 9 10 11 12"
str e3 lb4 e7 e8 e9 lb10 lb11 lb12
lb4=iamac
lb10=iafun
lb11=iaaut


will post full code when i have more time.
#6
@kevin
Thank you very much for your guidance Heart , I will try it carefully.


The following is a modified code according to your instructions, very good

I just found a little problem,

The Enter key cannot be used on other windows, for example, creating a new macro
Macro code:
Mes "ok"

Then from the search box, use the Enter key to open it, then press Enter again, the pop-up window can not be closed
Huh


Function Macro11
Code:
Copy      Help
out
QMITEM q; int i
ARRAY(str) aaut amac afun
rep
,i=qmitem(-i 2 &q 1)
,if(i=0) break
,sel q.itype
,,case 0
,,amac[]=q.name
,,case 1
,,afun[]=q.name
,,case 4
,,aaut[]=q.name
str iamac=amac
str iafun=afun
str iaaut=aaut

str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 409 163 "Dialog"
;3 Edit 0x54030080 0x200 5 22 96 14 ""
;7 Edit 0x54030080 0x204 106 22 96 14 ""
;8 Edit 0x54030080 0x204 207 22 96 14 ""
;9 Edit 0x54030080 0x204 308 22 96 14 ""
;4 ListBox 0x54230101 0x200 5 37 96 120 "" "Double click Run the Macro[]Right click Open the Macro"
;10 ListBox 0x54230101 0x204 106 37 96 120 "" "Double click Run the Funtion[]Right click Open the Funtion"
;11 ListBox 0x54230101 0x204 207 37 96 120 "" "Double click Open the AutoText"
;12 ListBox 0x54230101 0x204 308 37 96 120 "" "Double click Open the AutoText item"
;6 Static 0x54000000 0x0 37 8 48 12 "Macro"
;13 Static 0x54000000 0x0 133 8 48 12 "Function"
;14 Static 0x54000000 0x0 238 8 48 12 "Autotext"
;15 Static 0x54000000 0x0 333 8 48 12 "AutoText item"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 7 8 9 4 10 11 12"
str e3 e7 e8 e9 lb4 lb10 lb11 lb12
lb4=iamac
lb10=iafun
lb11=iaaut

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


#sub DlgProc v
function# hDlg message wParam lParam

;messages
sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Search Macro"
,SendMessage id(7 hDlg) EM_SETCUEBANNER TRUE @"Search Function"
,SendMessage id(8 hDlg) EM_SETCUEBANNER TRUE @"Search AutoText"
,SendMessage id(9 hDlg) EM_SETCUEBANNER TRUE @"Search AutoText item"
,
,SetProp id(8 hDlg) "wndproc" SubclassWindow((id(8 hDlg)) &sub.EditSubclassProc)
,SetProp id(3 hDlg) "wndproc" SubclassWindow((id(3 hDlg)) &sub.EditSubclassProc)
,SetProp id(7 hDlg) "wndproc" SubclassWindow((id(7 hDlg)) &sub.EditSubclassProc)
,
,case WM_DESTROY
,RemoveProp id(8 hDlg) "wndproc" ;;remove prop on dialog close
,RemoveProp id(3 hDlg) "wndproc" ;;remove prop on dialog close
,RemoveProp id(7 hDlg) "wndproc" ;;remove prop on dialog close
,
,case WM_COMMAND goto messages2
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hDlg wParam
,,goto giaaut
,,
,,;case 4
,,;KillTimer hDlg wParam
,,;goto giaati
,,
,,case 2
,,KillTimer hDlg wParam
,,goto giamac
,,
,,case 3
,,KillTimer hDlg wParam
,,goto giafun
ret
;messages2

int hlb12=id(12 hDlg) 

sel wParam
,case EN_CHANGE<<16|8
,SetTimer hDlg 1 100 0
,
,;case EN_CHANGE<<16|9
,;SetTimer hDlg 4 100 0
,
,case EN_CHANGE<<16|3
,SetTimer hDlg 2 100 0
,
,case EN_CHANGE<<16|7
,SetTimer hDlg 3 100 0
,
,case LBN_DBLCLK<<16|4
,goto gShowSelected4
,
,case LBN_DBLCLK<<16|10
,goto gShowSelected10
,
,case LBN_DBLCLK<<16|11
,goto gShowSelected11
,
,case LBN_SELCHANGE<<16|11
,str lb11si
,_i=LB_SelectedItem(lParam lb11si)
,str lb12ii itemslb12=sub.gotoitemedit(lb11si)
,SendMessage(hlb12 LB_RESETCONTENT 0 0)
,itemslb12.findreplace(":sub.Sub" "   ")
,itemslb12.findreplace(";;" "   ")
,foreach lb12ii itemslb12
,,LB_Add(hlb12 lb12ii)
,
,case LBN_DBLCLK<<16|12
,str lb12t
,_i=LB_SelectedItem(lParam lb12t)
,LB_SelectedItem id(11 hDlg) _s 
,;mes _s
,mac+ _s
,int c=GetQmCodeEditor
,SendMessage(c SCI.SCI_GOTOLINE _i+1 0)
,int ii=findrx(lb12t "\d" 0 1)
,int cp=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
,cp+ii
,SendMessage(c SCI.SCI_GOTOPOS cp 0)
,
,case IDOK
,case IDCANCEL
ret 1

;giamac
int hlb4=id(4 hDlg)
SendMessage hlb4 LB_RESETCONTENT 0 0
str s4 sEdit4.getwintext(id(3 hDlg)) 
foreach s4 iamac
,if(sEdit4.len and find(s4 sEdit4 0 1)<0) continue
,LB_Add hlb4 s4
ret

;giafun
int hlb10=id(10 hDlg)
SendMessage hlb10 LB_RESETCONTENT 0 0
str s10 sEdit10.getwintext(id(7 hDlg)) 
foreach s10 iafun
,if(sEdit10.len and find(s10 sEdit10 0 1)<0) continue
,LB_Add hlb10 s10
ret

;giaaut
int hlb11=id(11 hDlg)
SendMessage hlb11 LB_RESETCONTENT 0 0
str s11 sEdit11.getwintext(id(8 hDlg)) 
foreach s11 iaaut
,if(sEdit11.len and find(s11 sEdit11 0 1)<0) continue
,LB_Add hlb11 s11
ret

;giaati
;SendMessage hlb12 LB_RESETCONTENT 0 0
;str s12 sEdit12.getwintext(id(9 hDlg))
;ARRAY(str) iaati
;iaati=???
;foreach s12 iaati
,;if(sEdit12.len and find(s12 sEdit11 0 1)<0) continue
,;LB_Add hlb12 s12
;ret

;gShowSelected4
hlb4=id(4 hDlg)
_i=LB_SelectedItem(hlb4)
LB_GetItemText hlb4 _i _s 
mac _s
ret

;gShowSelected10
hlb10=id(10 hDlg)
_i=LB_SelectedItem(hlb10)
LB_GetItemText hlb10 _i _s
mac _s
ret

;gShowSelected11
hlb11=id(11 hDlg)
_i=LB_SelectedItem(hlb11)
LB_GetItemText hlb11 _i _s
mac+ _s
ret

#sub EditSubclassProc
function# hWnd message wParam lParam
int cid=GetDlgCtrlID(hWnd)
int Phwnd= GetParent(hWnd)
;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,case WM_GETDLGCODE
,sel(wParam) case [VK_RETURN] ret DLGC_WANTALLKEYS
,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam ;;virtual key code
,,case VK_RETURN
,,;on enter in the edit box select the item in the list box
,,sel cid
,,,case 3
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(4 Phwnd)) id(4 Phwnd)
,,,case 7
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(10 Phwnd)) id(10 Phwnd)
,,,case 8
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(11 Phwnd)) id(11 Phwnd)
,,ret
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,;relay these keys to the listbox and not to the edit box
,,sel cid
,,,case 3
,,,SendMessage id(4 Phwnd) message wParam lParam
,,,case 7
,,,SendMessage id(10 Phwnd) message wParam lParam
,,,case 8
,,,SendMessage id(11 Phwnd) message wParam lParam
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim
#7
I want to add the function of the right click to open the item, but it doesn't work. I don't understand the code below.
@kevin
How to add the following sub-function to the above code? 
Huh
 
Code:
Copy      Help
,case WM_RBUTTONUP
,Acc a.FromMouse
,int rcrn=a.Role
,str rcitem=a.Name
,if rcrn=34
,,int rccbh=a.Hwnd
,,int rciti= a.elem -1
,,mac "sub.rcmessage" "" rcrn rcitem rciti rccbh
,else
,,mac "sub.rcmessage" "" rcrn rcitem
 
Code:
Copy      Help
#sub rcmessage
function i [~item][itemindex][chwnd]
str mtext
sel i
,case 43:
,mtext="button was right clicked"
,,;mac+ item
,case 34:
,,;mtext.format("combo list item: (%s) was right clicked" item)
,,;CB_SelectItem(chwnd itemindex)
,,mac+ item
,case 33:
,,mtext="combo list was right clicked on an empty item"
if(!empty(mtext))
,mes(mtext)
#8
Again i think that there is something wrong with your qm as any function that has optional function arguments doesn't seem to work for you when it should.
#9
Is there any problem with the operating system?
I am using Simplified Chinese windows 7 64 bit


I often encounter situations where variables cannot be refreshed. New variables can only be used if QM is restarted.

I added a right click event and it succeeded, thanks   Tongue



Macro OK
Code:
Copy      Help
out
QMITEM q; int i
ARRAY(str) aaut amac afun
rep
,i=qmitem(-i 2 &q 1)
,if(i=0) break
,sel q.itype
,,case 0
,,amac[]=q.name
,,case 1
,,afun[]=q.name
,,case 4
,,aaut[]=q.name
str iamac=amac
str iafun=afun
str iaaut=aaut

str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 409 163 "Dialog"
;3 Edit 0x54030080 0x200 5 22 96 14 ""
;7 Edit 0x54030080 0x204 106 22 96 14 ""
;8 Edit 0x54030080 0x204 207 22 96 14 ""
;9 Edit 0x54030080 0x204 308 22 96 14 ""
;4 ListBox 0x54230101 0x200 5 37 96 120 "" "Double click Run the Macro[]Right click Open the Macro"
;10 ListBox 0x54230101 0x204 106 37 96 120 "" "Double click Run the Funtion[]Right click Open the Funtion"
;11 ListBox 0x54230101 0x204 207 37 96 120 "" "Double click Open the AutoText"
;12 ListBox 0x54230101 0x204 308 37 96 120 "" "Double click Open the AutoText item"
;6 Static 0x54000000 0x0 37 8 48 12 "Macro"
;13 Static 0x54000000 0x0 133 8 48 12 "Function"
;14 Static 0x54000000 0x0 238 8 48 12 "Autotext"
;15 Static 0x54000000 0x0 333 8 48 12 "AutoText item"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 7 8 9 4 10 11 12"
str e3 e7 e8 e9 lb4 lb10 lb11 lb12
lb4=iamac
lb10=iafun
lb11=iaaut

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


#sub DlgProc v
function# hDlg message wParam lParam

;messages
sel message
,case WM_INITDIALOG

,int hslb4=id(4 hDlg) ;;list
,SetWindowSubclass hslb4 &sub.WndProc_Subclass 1 0
,
,int hslb10=id(10 hDlg) ;;list
,SetWindowSubclass hslb10 &sub.WndProc_Subclass 1 0
,
,int hslb11=id(11 hDlg) ;;list
,SetWindowSubclass hslb11 &sub.WndProc_Subclass 1 0
,
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Search Macro"
,SendMessage id(7 hDlg) EM_SETCUEBANNER TRUE @"Search Function"
,SendMessage id(8 hDlg) EM_SETCUEBANNER TRUE @"Search AutoText"
,SendMessage id(9 hDlg) EM_SETCUEBANNER TRUE @"Search AutoText item"
,
,SetProp id(8 hDlg) "wndproc" SubclassWindow((id(8 hDlg)) &sub.EditSubclassProc)
,SetProp id(3 hDlg) "wndproc" SubclassWindow((id(3 hDlg)) &sub.EditSubclassProc)
,SetProp id(7 hDlg) "wndproc" SubclassWindow((id(7 hDlg)) &sub.EditSubclassProc)
,
,case WM_DESTROY
,RemoveProp id(8 hDlg) "wndproc" ;;remove prop on dialog close
,RemoveProp id(3 hDlg) "wndproc" ;;remove prop on dialog close
,RemoveProp id(7 hDlg) "wndproc" ;;remove prop on dialog close
,
,case WM_COMMAND goto messages2
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hDlg wParam
,,goto giaaut
,,
,,;case 4
,,;KillTimer hDlg wParam
,,;goto giaati
,,
,,case 2
,,KillTimer hDlg wParam
,,goto giamac
,,
,,case 3
,,KillTimer hDlg wParam
,,goto giafun
ret
;messages2

int hlb12=id(12 hDlg)

sel wParam
,case EN_CHANGE<<16|8
,SetTimer hDlg 1 100 0
,
,;case EN_CHANGE<<16|9
,;SetTimer hDlg 4 100 0
,
,case EN_CHANGE<<16|3
,SetTimer hDlg 2 100 0
,
,case EN_CHANGE<<16|7
,SetTimer hDlg 3 100 0
,
,case LBN_DBLCLK<<16|4
,goto gShowSelected4
,
,case LBN_DBLCLK<<16|10
,goto gShowSelected10
,
,case LBN_DBLCLK<<16|11
,goto gShowSelected11
,
,case LBN_SELCHANGE<<16|11
,str lb11si
,_i=LB_SelectedItem(lParam lb11si)
,str lb12ii itemslb12=sub.gotoitemedit(lb11si)
,SendMessage(hlb12 LB_RESETCONTENT 0 0)
,itemslb12.findreplace(":sub.Sub" "   ")
,itemslb12.findreplace(";;" "   ")
,foreach lb12ii itemslb12
,,LB_Add(hlb12 lb12ii)
,
,case LBN_DBLCLK<<16|12
,str lb12t
,_i=LB_SelectedItem(lParam lb12t)
,LB_SelectedItem id(11 hDlg) _s
,;mes _s
,mac+ _s
,int c=GetQmCodeEditor
,SendMessage(c SCI.SCI_GOTOLINE _i+1 0)
,int ii=findrx(lb12t "\d" 0 1)
,int cp=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
,cp+ii
,SendMessage(c SCI.SCI_GOTOPOS cp 0)
,
,case IDOK
,case IDCANCEL
ret 1

;giamac
int hlb4=id(4 hDlg)
SendMessage hlb4 LB_RESETCONTENT 0 0
str s4 sEdit4.getwintext(id(3 hDlg))
foreach s4 iamac
,if(sEdit4.len and find(s4 sEdit4 0 1)<0) continue
,LB_Add hlb4 s4
ret

;giafun
int hlb10=id(10 hDlg)
SendMessage hlb10 LB_RESETCONTENT 0 0
str s10 sEdit10.getwintext(id(7 hDlg))
foreach s10 iafun
,if(sEdit10.len and find(s10 sEdit10 0 1)<0) continue
,LB_Add hlb10 s10
ret

;giaaut
int hlb11=id(11 hDlg)
SendMessage hlb11 LB_RESETCONTENT 0 0
str s11 sEdit11.getwintext(id(8 hDlg))
foreach s11 iaaut
,if(sEdit11.len and find(s11 sEdit11 0 1)<0) continue
,LB_Add hlb11 s11
ret

;giaati
;SendMessage hlb12 LB_RESETCONTENT 0 0
;str s12 sEdit12.getwintext(id(9 hDlg))
;ARRAY(str) iaati
;iaati=???
;foreach s12 iaati
,;if(sEdit12.len and find(s12 sEdit11 0 1)<0) continue
,;LB_Add hlb12 s12
;ret

;gShowSelected4
hlb4=id(4 hDlg)
_i=LB_SelectedItem(hlb4)
LB_GetItemText hlb4 _i _s
mac _s
ret

;gShowSelected10
hlb10=id(10 hDlg)
_i=LB_SelectedItem(hlb10)
LB_GetItemText hlb10 _i _s
mac _s
ret

;gShowSelected11
hlb11=id(11 hDlg)
_i=LB_SelectedItem(hlb11)
LB_GetItemText hlb11 _i _s
mac+ _s
ret

#sub EditSubclassProc
function# hWnd message wParam lParam
int cid=GetDlgCtrlID(hWnd)
int Phwnd= GetParent(hWnd)
;OutWinMsg message wParam lParam
sel message
,case WM_DESTROY
,case WM_GETDLGCODE
,sel(wParam) case [VK_RETURN] ret DLGC_WANTALLKEYS
,case [WM_KEYDOWN,WM_KEYUP]
,sel wParam ;;virtual key code
,,case VK_RETURN
,,;on enter in the edit box select the item in the list box
,,sel cid
,,,case 3
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(4 Phwnd)) id(4 Phwnd)
,,,case 7
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(10 Phwnd)) id(10 Phwnd)
,,,case 8
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(11 Phwnd)) id(11 Phwnd)
,,ret
,,case [VK_DOWN,VK_UP,VK_PRIOR,VK_NEXT]
,,;relay these keys to the listbox and not to the edit box
,,sel cid
,,,case 3
,,,SendMessage id(4 Phwnd) message wParam lParam
,,,case 7
,,,SendMessage id(10 Phwnd) message wParam lParam
,,,case 8
,,,SendMessage id(11 Phwnd) message wParam lParam
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)

#sub gotoitemedit
function~ ~name

str pattern="(?:.*\:sub\..*)"

_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])

ret d.trim

#sub WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

;This function can be used with SetWindowSubclass as window procedure.
;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)

;OutWinMsg message wParam lParam ;;uncomment to see received messages
sel message
,case WM_RBUTTONUP
,Acc a.FromMouse
,int rcrn=a.Role
,str rcitem=a.Name
,if rcrn=34
,,int rccbh=a.Hwnd
,,int rciti= a.elem -1
,,mac "sub.rcmessage" "" rcrn rcitem rciti rccbh
,else
,,mac "sub.rcmessage" "" rcrn rcitem
int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass) ;;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass)
,;case ...

ret R

#sub rcmessage
function# i ~item #itemindex #chwnd
str mtext
sel i
,case 43:
,mtext="button was right clicked"
,case 34:
,,;mtext.format("combo list item: (%s) was right clicked" item)
,,CB_SelectItem(chwnd itemindex)
,,mac+ item
,case 33:
,,mtext="combo list was right clicked on an empty item"
if(!empty(mtext))
,mes(mtext)
#10
Can you tell me how the following parameters are obtained? I do not understand, thanks Heart

rcrn=34

    case 43:

    case 33:

OutWinMsg message wParam lParam ;;uncomment to see received messages

I use this line of commands to output parameters, but the output data is too much, how do I get the data I need?
#11
I found the answer  Smile
The acc object is too powerful  Tongue


sel message
    case WM_RBUTTONUP
    Acc a.FromMouse
    int rcrn=a.Role    
    mes rcrn  ;;34
    str rcitem=a.Name



Forum Jump:


Users browsing this thread: 1 Guest(s)