07-08-2016, 12:35 PM
This is what it came out finally. Any advice/comment is mostly welcome.
Function MenuDraw_FilMngmnt
Function MenuDraw_FilMngmnt
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : %s" NowT si _error.place si caller
;http://www.quickmacros.com/forum/viewtopic.php?p=31268
str simglo
int i
IStringMap MenuItems._create
lpstr s=
;100 _|I. Select Folder
;101 0|Explorer Folder|GetSetFlashFol(0)
;102 1|Folder in Registry|GetSetFlashFol(1)
;103 2|Display Folder in Registry|Display_Clip(1)
;104 3|Working Folder|GetSetFlashFol(2)
;105 4|Display Working Folder|Display_Clip(2)
;106 5|Downloads Folder|GetSetFlashFol(3)
;107 6|Image Files Folder|GetSetFlashFol(9 F"{MyTemp}\png")
;108 7|Icons Folder|GetSetFlashFol(9 "C:\Documents and Settings\S.E.Simopoulos\My Documents\Local Settings\sysman\icons\Ico")
;109 8|Τύπος
;110 8|Τύπος|GetSetFlashFol(9 "S:\SESdoc\ΕΜΠ-Πρυτανεία\Δημόσιες Σχέσεις\ΜΜΕ\Τύπος")
;111 9|Καθημερινή - Α.Λ.|FilTagDatim(0); GetSetFlashFol(9 "S:\SESdoc\ΕΜΠ-Πρυτανεία\Δημόσιες Σχέσεις\ΜΜΕ\Τύπος\Καθημερινή\Λακασάς Α")
;112 10|ETE IB Statement|SaveETEIBMF
;113 11|Financial Folders
;114 12|Μισθός - Σύνταξη |GetSetFlashFol(9 "S:\SESdoc\Lykaio\ΕΜΠ\ΣΕΣ\Μισθολογικά")
;115 13|Σύνταξη ΤΣΜΕΔΕ |GetSetFlashFol(9 "S:\SESdoc\Lykaio\ΕΜΠ\ΣΕΣ\Ασφαλιστικά\ΤΣΜΕΔΕ\Συνταξιοδοτικά\Παραστατικά")
;116 14|ΔΕΗ-Παγκράτι|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Κατοικία\ΔΕΗ\%ThisYear%")
;117 15|ΔΕΗ-Πόρτο Ράφτη|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Πόρτο-Ράφτη\ΔΕΗ")
;118 16|Ανω - 5012|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Πόρτο-Ράφτη\ΔΕΗ\706012935012_Ανω")
;119 17|Κάτω - 4018|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Πόρτο-Ράφτη\ΔΕΗ\706015064018_Κάτω")
;120 18|Πηγάδι - 4016|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Πόρτο-Ράφτη\ΔΕΗ\706015524016_Πηγάδι")
;121 19|ΕΥΔΑΠ|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Κατοικία\ΕΥΔΑΠ")
;122 15|Υδρευση Π-Ρ|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Πόρτο-Ράφτη\Υδρευση")
;123 20|Cosmote 6977784222|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Τηλέφωνα\Πάροχοι\Cosmote\6977784222\%ThisYear%")
;124 21|Πόρτο-Ράφτη 78080|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Τηλέφωνα\Πάροχοι\ΟΤΕ\78080")
;125 22|Wind|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Τηλέφωνα\Πάροχοι\Wind)
;126 23|Wind 1.29810627-6932229428-71370|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Τηλέφωνα\Πάροχοι\Wind\1.29810627-71370-2229428\%ThisYear%")
;127 24|Wind 1.30837977-6978996600-7013157|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Τηλέφωνα\Πάροχοι\Wind\1.30837977-7013157-6978996600\%ThisYear%")
;128 25|Wind 1.30837875-6936939289-7019090|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Τηλέφωνα\Πάροχοι\Wind\1.30837875-7019090-ΧΕΣ Mob\%ThisYear%")
;129 26|Ασφάλιστρα Αυτοκινήτου|GetSetFlashFol(9 "S:\SESdoc\Προσωπικά\Αυτοκίνητα\IMT5317\Ασφάλεια")
;130 27|Κίνηση-082 Ετους|GetSetFlashFol(9 "%SESdoc%\Προσωπικά\Banks\ETE\Κίνηση\%ThisYear%")
;131 28|Display Current Path Length|CheckPathLength
;132 29|Display File Length|CheckFileOELength
;133 30|Display Current Folder|_s=OEMConstructComboPath; Task_Message _s 0 0xFF0000
;134 31|Display Current File|DisplayCurrentFile
;135 32|File tag Date|Paste_Date
;136 33|File tag Time|Paste_Date_Time
;137 34|Check File Length|Report_SavedF
;138 35|Shrink File Length|Shrink_SavedF
;139 36|Display Files Management Toolbar|OpSavMisc(win())
;140 _|II. FileSystem Routines
;141 _|III. Filename Modification Routines
;142 _|IV. Filename Length Routines
;143 _|V. Other
MenuItems.AddList(s)
IStringMap- label._create; label.Flags=1
IStringMap- qmi._create; label.Flags=1
ARRAY(str) arr ak av
MenuItems.GetAll(ak av)
int j
for(i 0 ak.len)
,j=tok(av[i] arr 3 "|" 0x2000)
,if j<2
,,_s=F"Tok error on key {ak[i]} - {av[i]} - Caller : <open>{caller}</open> "
,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,mac "Warning_QM" si 0
,,end
,if StrCompare(arr[0] "_")<>0; simglo.formata(F"{ak[i]}={arr[0]} ")
,label.Add(ak[i] arr[1])
,if j=3; qmi.Add(ak[i] arr[2])
;out simglo
simglo.rtrim
;simglo.left(simglo 261)
;out simglo
SetThreadMenuIcons simglo "$my qm$\imagelists\FilMngmnt.bmp" 1
str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;3 Button 0x54032000 0x0 8 8 48 14 "Popup menu"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040308 "*" "" "" ""
if(!ShowDialog(dd &sub.DlgProc 0 0 0 0 0 0 0 0 0 sub.GetMenuDef)) ret
#sub DlgProc
function# hDlg message wParam lParam
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : %s" NowT si _error.place si caller
sel message
,case WM_INITDIALOG
,but+ id(3, hDlg)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,
,case WM_MEASUREITEM
,sel wParam
,,case 0
,,sub.MeasureMenuItem hDlg +lParam
,,ret DT_Ret(hDlg 1)
,
,case WM_DRAWITEM
,sel wParam
,,case 0
,,sub.DrawMenuItem hDlg +lParam
,,ret DT_Ret(hDlg 1)
ret
;messages2
;OutWinMsg message wParam lParam
IStringMap- qmi
sel wParam
,case 3 ;;Popup menu
,int i=ShowMenu(sub.GetMenuDef hDlg)
,lpstr v=qmi.Get(F"{i}")
,outt F"{i} | {v}"
,if(v)
,,RunTextAsFunction2(v)
,else
,,_s=F"Value not found for key {i} - Caller : <open>{caller}</open> "
,,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,mac "Warning_QM" si 0
,,end
,
,end
,
,
,case IDOK
,case IDCANCEL
ret 1
#sub GetMenuDef
function~
str md=
;BEGIN MENU
;I. Select Folder : 100 0x100 0x3
;Explorer Folder : 101 0x100 0x0
;Folder in Registry : 102 0x100 0x0
;Display Folder in Registry : 103 0x100 0x0
;Working Folder : 104 0x100 0x0
;Display Working Folder : 105 0x100 0x0
;Downloads Folder : 106 0x100 0x0
;Image Files Folder : 107 0x100 0x0
;Icons Folder : 108 0x100 0x0
;>Τύπος : 109 0x100
;,Τύπος : 110 0x100 0x0
;,Καθημερινή - Α.Λ. : 111 0x100 0x0
;<
;ETE IB Statement : 112 0x100 0x0
;>Financial Folders : 113 0x100 0x0
;Μισθός - Σύνταξη : 114 0x100 0x0
;Σύνταξη ΤΣΜΕΔΕ : 115 0x100 0x0
;-
;ΔΕΗ-Παγκράτι : 116 0x100 0x0
;ΔΕΗ-Πόρτο Ράφτη : 117 0x100 0x0
;Ανω - 5012 : 118 0x100 0x0
;Κάτω - 4018 : 119 0x100 0x0
;Πηγάδι - 4016 : 120 0x100 0x0
;-
;ΕΥΔΑΠ : 121 0x100 0x0
;Υδρευση Π-Ρ : 122 0x100 0x0
;-
;Cosmote 6977784222 : 123 0x100 0x0
;Πόρτο-Ράφτη 78080 : 124 0x100 0x0
;-
;Wind : 125 0x100 0x0
;Wind 1.29810627-6932229428-71370 : 126 0x100 0x0
;Wind 1.30837977-6978996600-7013157 : 127 0x100 0x0
;Wind 1.30837875-6936939289-7019090 : 128 0x100 0x0
;-
;Ασφάλιστρα Αυτοκινήτου : 129 0x100 0x0
;-
;Κίνηση-082 Ετους : 130 0x100 0x0
;<
;-
;II. : 140 0x100 0x3
;Display Current Path Length : 131 0x100 0x0
;Display File Length : 132 0x100 0x0
;Display Current Folder : 133 0x100 0x0
;Display Current File : 134 0x100 0x0
;-
;III. : 141 0x100 0x3
;File tag Date : 135 0x100 0x0
;File tag Time : 136 0x100 0x0
;-
;IV. : 142 0x100 0x3
;Check File Length : 137 0x100 0x0
;Shrink File Length : 138 0x100 0x0
;-
;V. : 143 0x100 0x3
;Display Files Management Toolbar : 139 0x100 0x0
;END MENU
ret md
#sub MeasureMenuItem
function hDlg MEASUREITEMSTRUCT&m
m.itemWidth=200 ;;there are several API functions to get string width, for example GetTextExtentPoint32W
m.itemWidth+24 ;;add space for icon or checkbox
;if(m.itemHeight<18) m.itemHeight=18 ;;icon height + 2 pixels between icons
if(m.itemHeight<24) m.itemHeight=24 ;;icon height + 2 pixels between icons
#sub DrawMenuItem
function hDlg DRAWITEMSTRUCT&d
str si.getmacro(getopt(itemid) 1)
str caller.getmacro(getopt(itemid 1) 1);err caller=si
if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : %s" NowT si _error.place si caller
IStringMap- label
int hdc=d.hDC
RECT r=d.rcItem
int selected(d.itemState&ODS_SELECTED) disabled(d.itemState&ODS_DISABLED)
FillRect hdc &r iif(selected COLOR_HIGHLIGHT COLOR_MENU)+1
;this code gets default text color. Change it if need other color.
int col=-1
int color
if d.itemID=103 ; color=475617
if d.itemID=105 ; color=108031
if(disabled)
;,col=GetSysColor(COLOR_GRAYTEXT)
;,https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx
,col=GetSysColor(COLOR_HOTLIGHT)
else
,if(selected)
,,col=GetSysColor(COLOR_HIGHLIGHTTEXT)
,else
,,col=iif(color color GetSysColor(COLOR_MENUTEXT))
SetTextColor(hdc col)
SetBkMode(hdc TRANSPARENT)
BSTR b
lpstr v=label.Get(F"{d.itemID}")
if(v)
,b=v
else
,_s=F"Value not found for key {d.itemID} - Caller : <open>{caller}</open> "
,min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" si 0
,end
;BSTR b="Menu item text" ;;this should be retrieved from array that you create before showing menu
r.left+24 ;;add space for icon or checkbox, which you can draw here or use SetThreadMenuIcons
r.top+1
DrawTextW(hdc b b.len &r DT_END_ELLIPSIS)