12-07-2013, 04:42 PM
Function SelCurrentQmFolder
Let the dialog call this function on WM_INITDIALOG, and select page.
Example.
Function Dialog139
A function or macro in folder S1 or S2.
;/
function# $folders
;Finds in which of specified QM folders is currently open in editor QM item.
;Returns 1-based index of string in the folders list.
;Returns 0 if current item is not in one of specified folders.
;folders - multiline list of QM folder names.
;REMARKS
;Unavailable in exe.
;EXAMPLE
;int i=SelCurrentQmFolder("Folder A[]Folder B")
;out i ;;1 if current open macro is in folder "Folder A", 2 if in "Folder B", else 0
;get ancestor folder names
ARRAY(str) a
QMITEM q
qmitem "" 0 q 16
rep
,if(!q.folderid) break
,qmitem q.folderid 0 q 17
,a[]=q.name
;out a
str s; int i R
foreach s folders
,R+1
,for(i 0 a.len) if(s~a[i]) ret RLet the dialog call this function on WM_INITDIALOG, and select page.
Example.
Function Dialog139
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str lb3
lb3="Page0[]Page1[]Page2"
if(!ShowDialog("Dialog139" &Dialog139 &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 265 163 "Dialog"
;3 ListBox 0x54230101 0x204 4 4 96 80 ""
;1001 Static 0x54020000 0x4 106 4 48 13 "Page0"
;1101 Static 0x54020000 0x4 106 4 48 13 "Page1"
;1201 Static 0x54020000 0x4 106 4 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;5 Static 0x54000010 0x20004 0 138 800 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030606 "" "0" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,int page
#if !EXE
,page=SelCurrentQmFolder("S1[]S2")-1
#endif
,LB_SelectItem id(3 hDlg) page
,DT_Page hDlg page
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case LBN_SELCHANGE<<16|3
,_i=LB_SelectedItem(id(3 hDlg))
,DT_Page hDlg _i
ret 1