SCI_SETSELFORE(bool useSetting, colour fore) SCI_SETSELBACK(bool useSetting, colour back)
You can choose to override the default selection colouring with these two messages. The colour you provide is used if you set @kevin
If highlight the line (set the background color to yellow), it would be great.
How to exchange positions, is it possible?
Like the picture below
04-20-2019, 01:14 AM (This post was last modified: 04-20-2019, 01:28 AM by win.)
I saw the following code in QM help, I think there should be a way to exchange the position of Sub* and Abbre, but I don't know how to use regular expressions.
If need month, day and year:
ARRAY(str) a
i=findrx("file01-02-2000.txt" "(\d{2})-(\d{2})-(\d{4})" 0 0 a)
out a[0] ;;whole match
out a[1] ;;submatch 1 (month)
out a[2] ;;submatch 2 (day)
out a[3] ;;submatch 3 (year)
sel message ,caseWM_INITDIALOG ,SendMessageid(3 hDlg)EM_SETCUEBANNERTRUE@"Enter Text" ,SendMessageid(4 hDlg)EM_SETCUEBANNERTRUE@"Enter Statements" ,SendMessageid(12 hDlg)EM_SETCUEBANNERTRUE@"Enter Comment" ,SendMessageid(5 hDlg)CB_SETCUEBANNER0@"Select Autotext file to add text to" ,DT_SetAccelerators(hDlg "400 Az") ,caseWM_DESTROY ,caseWM_COMMANDgoto messages2 ret ;messages2 sel wParam ,caseCBN_EDITCHANGE<<16|5 ,sub.CB_AutoComplete lParam ,caseIDOK ,caseIDCANCEL ,case10;;Add ,DT_Ok hDlg ,case13;;Multiline/Singlelin Autotext ,hidid(15 hDlg) ,hidid(16 hDlg) ,hidid(17 hDlg) ,case9;;Template for KeyAutoInputDialog ,hid-id(15 hDlg) ,hid-id(16 hDlg) ,hid-id(17 hDlg) ,case [15,400];;+ inp_name ,_s.getsel(00id(4 hDlg)) ,if _s.len ,,str s.from("$inp_" _s "$") ,,s.setsel(0id(4 hDlg)) ,else ,,mes"You must first select a word in the edit box" ,case16;;+ sel_name ,str aid_sel=sub.Get_AID_sel_AID_var("sel") ,_i=ListDialog(aid_sel "Select an option from the list below""AID_sel") ,if(_i=0)ret ,aid_sel.getl(aid_sel _i-1) ,actid(4 hDlg) ,paste aid_sel ,case17;;+ var_name ,str aid_var=sub.Get_AID_sel_AID_var("var") ,_i=ListDialog(aid_var "Select an option from the list below""AID_var") ,if(_i=0)ret ,aid_var.getl(aid_var _i-1) ,actid(4 hDlg) ,paste aid_var ret1
#sub GetInsertedTextCaretPosition function# [flags] ;;flags: 1 go to that position int c=GetQmCodeEditor SendMessage(c SCI.SCI_UNDO00) int r=SendMessage(c SCI.SCI_GETCURRENTPOS00) SendMessage(c SCI.SCI_REDO00) if(flags&1)SendMessage(c SCI.SCI_GOTOPOS r 0) ret r
#sub CB_AutoComplete function hcb
ifk(B)ret ifk(X)ret str s ss;int i
s.getwintext(hcb) if(s.len) ,i=CB_FindItem(hcb s) ,if(i>=0) ,,CB_GetItemText(hcb i ss) ,,if(ss.len>s.len) ,,,ss.setwintext(hcb) ,,,SendMessage(hcb CB_SETEDITSEL0 ss.len<<16|s.len) #sub Get_AID_sel_AID_var function~~option str oName pattern sel option ,case"sel" ,oName="AID_sel" ,pattern="\$(?:sel)_(.+?)\$" ,case"var" ,oName="AID_var" ,pattern="\$(?:var)_(.+?)\$"
_s.getmacro(oName 0) str ss d int i ARRAY(str) aid_S foreach ss _s ,findrx(ss pattern 04 aid_S) ,for i 0 aid_S.len ,,d.formata("%s[]" aid_S[0 i]) ret d.trim
#sub check_for_comment function curPos h ~comment str s ss if(!h); h=GetQmCodeEditor int line=SendMessage(h SCI.SCI_LINEFROMPOSITION curPos 0) SendMessage(h SCI.SCI_GOTOLINE line 0) int sp=SendMessage(h SCI.SCI_POSITIONFROMLINE line 0); int ep=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0) int ll=ep-sp
s.fix(SendMessage(h SCI.SCI_GETLINE line s.all(ll+1)))
s.trim if(findrx(s ";;")<0) ,ss.from(";;" comment) ,SendMessage(h SCI.SCI_GOTOPOS ep 0) ,SendMessage(h SCI.SCI_INSERTTEXT-1 ss)
sel message ,caseWM_INITDIALOG ,SendMessageid(3 hDlg)EM_SETCUEBANNERTRUE@"Enter Text" ,SendMessageid(4 hDlg)EM_SETCUEBANNERTRUE@"Enter Statements" ,SendMessageid(12 hDlg)EM_SETCUEBANNERTRUE@"Enter Comment" ,SendMessageid(5 hDlg)CB_SETCUEBANNER0@"Select Autotext file to add text to" ,DT_SetAccelerators(hDlg "400 Az") ,caseWM_DESTROY ,caseWM_COMMANDgoto messages2 ret ;messages2 sel wParam ,caseCBN_EDITCHANGE<<16|5 ,sub.CB_AutoComplete lParam ,caseIDOK ,caseIDCANCEL ,case10;;Add ,DT_Ok hDlg ,case13;;Multiline/Singlelin Autotext ,hidid(15 hDlg) ,hidid(16 hDlg) ,hidid(17 hDlg) ,case9;;Template for KeyAutoInputDialog ,hid-id(15 hDlg) ,hid-id(16 hDlg) ,hid-id(17 hDlg) ,case [15,400];;+ inp_name ,_s.getsel(00id(4 hDlg)) ,if _s.len ,,str s.from("$inp_" _s "$") ,,s.setsel(0id(4 hDlg)) ,else ,,mes"You must first select a word in the edit box" ,case16;;+ sel_name ,str aid_sel=sub.Get_AID_sel_AID_var("sel") ,_i=ListDialog(aid_sel "Select an option from the list below""AID_sel") ,if(_i=0)ret ,aid_sel.getl(aid_sel _i-1) ,actid(4 hDlg) ,paste aid_sel ,case17;;+ var_name ,str aid_var=sub.Get_AID_sel_AID_var("var") ,_i=ListDialog(aid_var "Select an option from the list below""AID_var") ,if(_i=0)ret ,aid_var.getl(aid_var _i-1) ,actid(4 hDlg) ,paste aid_var ret1
#sub GetInsertedTextCaretPosition function# [flags] ;;flags: 1 go to that position int c=GetQmCodeEditor SendMessage(c SCI.SCI_UNDO00) int r=SendMessage(c SCI.SCI_GETCURRENTPOS00) SendMessage(c SCI.SCI_REDO00) if(flags&1)SendMessage(c SCI.SCI_GOTOPOS r 0) ret r
#sub CB_AutoComplete function hcb
ifk(B)ret ifk(X)ret str s ss;int i
s.getwintext(hcb) if(s.len) ,i=CB_FindItem(hcb s) ,if(i>=0) ,,CB_GetItemText(hcb i ss) ,,if(ss.len>s.len) ,,,ss.setwintext(hcb) ,,,SendMessage(hcb CB_SETEDITSEL0 ss.len<<16|s.len) #sub Get_AID_sel_AID_var function~~option str oName pattern sel option ,case"sel" ,oName="AID_sel" ,pattern="\$(?:sel)_(.+?)\$" ,case"var" ,oName="AID_var" ,pattern="\$(?:var)_(.+?)\$"
_s.getmacro(oName 0) str ss d int i ARRAY(str) aid_S foreach ss _s ,findrx(ss pattern 04 aid_S) ,for i 0 aid_S.len ,,d.formata("%s[]" aid_S[0 i]) ret d.trim
#sub check_for_comment function curPos h ~comment str s ss if(!h); h=GetQmCodeEditor int line=SendMessage(h SCI.SCI_LINEFROMPOSITION curPos 0) SendMessage(h SCI.SCI_GOTOLINE line 0) int sp=SendMessage(h SCI.SCI_POSITIONFROMLINE line 0); int ep=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0) int ll=ep-sp
s.fix(SendMessage(h SCI.SCI_GETLINE line s.all(ll+1)))
s.trim if(findrx(s ";;")<0) ,ss.from(";;" comment) ,SendMessage(h SCI.SCI_GOTOPOS ep 0) ,SendMessage(h SCI.SCI_INSERTTEXT-1 ss)
#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) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
#sub EditSubclassProc function# hWnd message wParam lParam int cid=GetDlgCtrlID(hWnd) int Phwnd=GetParent(hWnd) ;OutWinMsg message wParam lParam sel message ,caseWM_DESTROY , ,caseWM_GETDLGCODE ,sel wParam ,,caseVK_RETURN ,,retDLGC_WANTALLKEYS , ,case [WM_KEYDOWN,WM_KEYUP] ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel cid ,,,case8 ,,,SendMessage Phwnd WM_COMMANDLBN_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 ,,,case8 ,,,SendMessageid(11 Phwnd) message wParam lParam ,,ret
int wndproc=GetProp(hWnd "wndproc");if(!wndproc)ret retCallWindowProcW(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 04 a) for i 0 a.len ,d.formata("%s[]" a[0 i])
#sub gotoitemedit function~~name str pattern="(?m)^(.+\:.+)"
_s.getmacro(name 0) str ss d int i ARRAY(str) a findrx(_s pattern 04 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) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
#sub EditSubclassProc function# hWnd message wParam lParam int cid=GetDlgCtrlID(hWnd) int Phwnd=GetParent(hWnd) ;OutWinMsg message wParam lParam sel message ,caseWM_DESTROY ,caseWM_GETDLGCODE ,sel wParam ,,caseVK_RETURN ,,retDLGC_WANTALLKEYS ,case [WM_KEYDOWN] ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel cid ,,,case3 ,,,SendMessage Phwnd WM_COMMANDLBN_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd))id(4 Phwnd) ,,,case5 ,,,SendMessage Phwnd WM_COMMANDLBN_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 ,,,case3 ,,,SendMessageid(4 Phwnd) message wParam lParam ,,,case5 ,,,SendMessageid(6 Phwnd) message wParam lParam ,,ret
int wndproc=GetProp(hWnd "wndproc");if(!wndproc)ret retCallWindowProcW(wndproc hWnd message wParam lParam)
04-30-2019, 05:50 AM (This post was last modified: 04-30-2019, 07:35 AM by win.)
I added the following code
Enter directly on the edit box (e3) , unable to open the first Item,
Double click can open Item succeed
In addition, there is always an extra alarm sound When I press Enter on the AutoText item, it will sound, and when it is positioned in the file, it will sound again.
#sub gotoitemedit function~~name str pattern="(?m)^(.+\s\:.+)"
_s.getmacro(name 0) str ss d int i ARRAY(str) a findrx(_s pattern 04 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) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
#sub EditSubclassProc function# hWnd message wParam lParam int cid=GetDlgCtrlID(hWnd) int Phwnd=GetParent(hWnd) ;OutWinMsg message wParam lParam sel message ,caseWM_DESTROY ,caseWM_GETDLGCODE ,sel wParam ,,caseVK_RETURN ,,retDLGC_WANTALLKEYS ,caseWM_CHAR ,sel wParam ,,caseVK_RETURN ,,sel cid ,,,case [3,5] ,,,ret0 ,caseWM_KEYDOWN ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel cid ,,,case3 ,,,SendMessage Phwnd WM_COMMANDLBN_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd))id(4 Phwnd) ,,,case5 ,,,SendMessage Phwnd WM_COMMANDLBN_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 ,,,case3 ,,,SendMessageid(4 Phwnd) message wParam lParam ,,,case5 ,,,SendMessageid(6 Phwnd) message wParam lParam ,,ret
int wndproc=GetProp(hWnd "wndproc");if(!wndproc)ret retCallWindowProcW(wndproc hWnd message wParam lParam)
The edit 3 control is programmed to open at items in list box 6. The main point of edit 3 and listbox 4 is to open the it autotext items in listbox 6.You already have double click to open the auto text function. It's redundant. And counter intuitive to what the edit control does.
#sub gotoitemedit function~~name str pattern="(?m)^(.+\s\:.+)"
_s.getmacro(name 0) str ss d int i ARRAY(str) a findrx(_s pattern 04 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) rep4 ,SendMessage(hce SCI.SCI_INDICATORFILLRANGE lsp lep-lsp) ,0.25 ,SendMessage(hce SCI.SCI_INDICATORCLEARRANGE lsp lep-lsp) ,0.25 SendMessage(hce SCI.SCI_SETINDICATORCURRENT00)
#sub EditSubclassProc function# hWnd message wParam lParam int cid=GetDlgCtrlID(hWnd) int Phwnd=GetParent(hWnd) ;OutWinMsg message wParam lParam sel message ,caseWM_DESTROY ,caseWM_GETDLGCODE ,sel wParam ,,caseVK_RETURN ,,retDLGC_WANTALLKEYS ,caseWM_CHAR ,sel wParam ,,caseVK_RETURN ,,sel cid ,,,case [3,5] ,,,ret0 ,caseWM_KEYDOWN ,sel wParam ;;virtual key code ,,caseVK_RETURN ,,;on enter in the edit box select the item in the list box ,,sel cid ,,,case3 ,,,SendMessage Phwnd WM_COMMANDLBN_SELCHANGE<<16|GetDlgCtrlID(id(4 Phwnd))id(4 Phwnd) ,,,case5 ,,,SendMessage Phwnd WM_COMMANDLBN_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 ,,,case3 ,,,SendMessageid(4 Phwnd) message wParam lParam ,,,case5 ,,,SendMessageid(6 Phwnd) message wParam lParam ,,ret
int wndproc=GetProp(hWnd "wndproc");if(!wndproc)ret retCallWindowProcW(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 ,,,case1 ,,,dis+ q.name ,,,caseelse ,,,dis- q.name if mode <>1 ,ret
atItems=atn
05-01-2019, 12:57 AM (This post was last modified: 05-01-2019, 01:10 AM by win.)
Well, I agree with your thoughts. The above method of disabling all the autotext is a bit situation.
I have disabled some items before, After using the code, it all enabled.
If the comment text is long, it cannot be displayed in the list box. Please see the picture below
I have an idea.
When the mouse hovers over the item, a prompt will display, the content is the text of the comment.
05-01-2019, 01:28 AM (This post was last modified: 05-01-2019, 01:35 AM by Kevin.)
2 possibilities
1. would need to measure text length and set horizontal scrollbar width. listbox does not automatically adjust horizontal scrollbar has to be programmed.
2. change list box to SysListView32 but would require more programming.
as far as your other issue i guess i could make a list of items that are already disabled and when the Enable part of the function runs check that list and skip those items.