Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get a list of all AutoText files in the left pane
this will take care of the autotex  triggering while the dialog is open  and will enable all autotext triggers when dialog closes

Function Dialog_Edit_Autotext
Code:
Copy      Help
out
str- sItems        
sub.DisableEnableAutoText(1 sItems)         

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 188 "Edit Existing AutoText"
;3 Edit 0x54030080 0x200 9 8 120 14 ""
;4 ListBox 0x54230101 0x200 9 22 120 157 ""
;5 Edit 0x54030080 0x200 145 8 174 14 ""
;6 ListBox 0x54230101 0x200 145 22 174 157 ""
;1 Button 0x54030001 0x4 116 200 48 14 "OK"
;2 Button 0x54030000 0x4 168 200 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

str controls = "3 4 5 6"
str e3 lb4 e5 lb6
lb4=sItems
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
str- itemslb2
int- lb6lc
str- sItems
int i
sel message
,case WM_INITDIALOG
,SetProp id(3 hDlg) "wndproc" SubclassWindow((id(3 hDlg)) &sub.EditSubclassProc)
,SetProp id(5 hDlg) "wndproc" SubclassWindow((id(5 hDlg)) &sub.EditSubclassProc)
,case WM_DESTROY
,RemoveProp id(3 hDlg) "wndproc"
,RemoveProp id(5 hDlg) "wndproc"    
,case WM_COMMAND goto messages2
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hDlg wParam
,,int hlb=id(4 hDlg)
,,SendMessage hlb LB_RESETCONTENT 0 0
,,str s3 sEdit3.getwintext(id(3 hDlg))
,,foreach s3 sItems
,,,if(sEdit3.len and find(s3 sEdit3 0 1)<0) continue
,,,LB_Add hlb s3
,,int count=LB_GetCount(hlb)
,,if count=1
,,,SendMessage hDlg WM_COMMAND LBN_SELCHANGE<<16|GetDlgCtrlID(id(4 hDlg)) id(4 hDlg)
,,,;LB_SelectItem(hlb 0)
,,case 2
,,KillTimer hDlg wParam
,,int hlb2a=id(6 hDlg)
,,SendMessage hlb2a LB_RESETCONTENT 0 0
,,str s5 sEdit5.getwintext(id(5 hDlg))
,,foreach s5 itemslb2
,,,if(sEdit5.len and find(s5 sEdit5 0 1)<0) continue
,,,LB_Add hlb2a s5
,,int count2=LB_GetCount(hlb2a)
,,if count2=1
,,,LB_SelectItem(hlb2a 0)    
ret
;messages2
int h=GetQmCodeEditor
int hlb2=id(6 hDlg) ;;list box 2
sel wParam
,case IDOK
,sub.DisableEnableAutoText(2)
,case IDCANCEL
,sub.DisableEnableAutoText(3)
,case EN_CHANGE<<16|3
,SetTimer hDlg 1 100 0
,case EN_CHANGE<<16|5
,SetTimer hDlg 2 100 0    
,case LBN_SELCHANGE<<16|4
,str lb1si
,_i=LB_SelectedItem(lParam lb1si)
,if(_i=-1)
,,LB_SelectItem(lParam 0)
,,_i=LB_SelectedItem(lParam lb1si)
,str lb2ii 
,itemslb2=sub.gotoitemedit(lb1si)
,SendMessage(hlb2 LB_RESETCONTENT 0 0)
,itemslb2.findreplace(":sub." "     ")
,itemslb2.findreplace(";;" "     ")
,itemslb2.findreplace(":" "     ")
,foreach lb2ii itemslb2
,,LB_Add(hlb2 lb2ii)    
,lb6lc=LB_GetCount(hlb2)
,case LBN_DBLCLK<<16|4
,_i=LB_SelectedItem(lParam _s)
,mac+ _s    
,case LBN_DBLCLK<<16|6
,str lb2t
,_i=LB_SelectedItem(lParam lb2t)
,if(_i=-1)
,,LB_SelectItem(lParam 0)
,,_i=LB_SelectedItem(lParam lb2t)
,int lb6ic=LB_GetCount(lParam)
,if(lb6ic<>lb6lc)
,,ARRAY(str) b=itemslb2
,,for i 0 b.len
,,,if(StrCompare(b[i] lb2t)=0)
,,,,_i=i
,,,,break
,LB_SelectedItem(id(4 hDlg)  _s)
,mac+ _s
,SendMessage(h SCI.SCI_GOTOLINE _i+1 0)
,int ii=findrx(lb2t "Sub." 0 1)
,if ii!=-1
,,int cp=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
,,cp+ii
,,SendMessage(h SCI.SCI_GOTOPOS cp 0)
,sub.FlashCodeLine(_i+1 h)
ret 1

#sub gotoitemedit
function~ ~name
str pattern="(?m)^(.+\s\:.+)"
_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 FlashCodeLine
function line hce
if(!hce) hce=GetQmCodeEditor
int indicator=9
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)

#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_CHAR
,sel wParam
,,case VK_RETURN
,,sel cid
,,,case [3,5]
,,,ret 0
,case WM_KEYDOWN
,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_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd)) id(4 Phwnd)
,,,case 5
,,,SendMessage Phwnd WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(id(6 Phwnd)) id(6 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 5
,,,SendMessage id(6 Phwnd) message wParam lParam            
,,ret

int wndproc=GetProp(hWnd "wndproc"); if(!wndproc) ret
ret CallWindowProcW(wndproc hWnd message wParam lParam)
#sub DisableEnableAutoText 
function mode [str&atItems]
QMITEM q; int i
ARRAY(str) atn
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,sel mode
,,,case 1
,,,dis+ q.name
,,,case else
,,,dis- q.name
if mode <>1
,ret
atItems=atn


Messages In This Thread
RE: How to get a list of all AutoText files in the left pane - by Kevin - 05-01-2019, 12:27 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)