1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
function TContextTools.QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst,
idCmdLast, uFlags: UINT): HResult;
Const
Caption:String='Modifier l''extension';
var
Command_ID,
hSub_Menu : HMenu;
MenuInfo : TMenuItemInfo;
begin
Result:= 0;
if ((uFlags and $0000000F) = CMF_NORMAL) or
((uFlags and CMF_EXPLORE) <> 0) then
begin
MenuIndex1 := indexMenu; // index du sous menu
Command_ID := idCmdFirst;
MenuInfo.cbSize := SizeOf(MenuInfo);
hSub_Menu := CreateMenu;
Inc(Command_ID);
MenuIndex2 := MenuIndex1+1; // index de l'entrée du sous menu
InsertMenu(hSub_Menu,MenuIndex2,MF_BYPOSITION or MF_STRING,Command_ID,'Copier et renommer en 001');
Inc(Command_ID);
MenuIndex3 := MenuIndex2+1;
InsertMenu(hSub_Menu,MenuIndex3,MF_BYPOSITION or MF_STRING,Command_ID,'Renommer en 001');
{
si d'autre entrées :
Inc(Command_ID);
MenuIndex4 := MenuIndex3+1;
InsertMenu(hSub_Menu,MenuIndex4,MF_BYPOSITION or MF_STRING,Command_ID,'Third Memu Itrm');
}
With MenuInfo do
begin
fMask := MIIM_ID or MIIM_SUBMENU or MIIM_TYPE;
fType := MFT_STRING;
fState := 0;
dwTypeData :=Pchar(Caption);
cch := Length(Caption); // 20 :longueur de chaine;
hSubMenu := hSub_Menu;
wID := idCmdFirst;
hbmpChecked := 0;
hbmpUnchecked := 0;
end;
InsertMenuItem(Menu,MenuIndex1,True,MenuInfo);
Result := 3{ 1 sous-Menu +2 entrées};
end;
end;
Avec les variables suivantes déclarées dans la classe
TContextTools = class(TComObject, IShellExtInit, IContextMenu)
FFileName : array[0..MAX_PATH] of Char;
MenuIndex1, MenuIndex2, MenuIndex3 : UINT; |
Partager