2012-10-11 66 views
11

Esta puede ser una pregunta fácil, pero ni siquiera estoy seguro de la terminología para buscar, así que tengo que preguntar. Quiero que mi programa tenga un menú cuando está suspendido sobre si está fijado al menú de inicio. Adjunto una captura de pantalla donde Windows powershell ilustra esta función y presenta una lista de tareas.¿Cómo puedo crear un menú en el menú de inicio de mi programa?

enter image description here

Otros programas utilizan a veces esta a la lista de archivos abiertos recientemente, etc. Estoy seguro de que esto es suficiente estándar que hay un tutorial sobre alguna parte, sería alguien mente me apuntando a la misma, o explicar cómo ¿hacer esto? Espero que no importe demasiado qué idioma se usa, pero soy competente en Delphi, C++ y C#.

Respuesta

12

debe utilizar el método de ICustomDestinationList.AddUserTasks, que es parte de la Taskbar Extensions introducido en Windows 7.

ACTUALIZACIÓN

Pruebe esta aplicación de consola de ejemplo, ejecute el código y mover un acceso directo de la aplicación para el comienzo menú. (Esto es sólo un fragmento de la muestra, así que recuerde agregar los cheques por el resultado de todos los métodos que devuelven un valor HResult)

program ProjectTasks; 

{$APPTYPE CONSOLE} 

{$R *.res} 

uses 
    SysUtils, 
    ActiveX, 
    windows, 
    ComObj, 
    ShlObj, 
    PropSys, 
    ObjectArray; 

const 
    PKEY_TITLE : TPropertyKey = (fmtID : '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}'; pID : 2); 

procedure CreateTaskList; 
var 
    LCustomDestinationList : ICustomDestinationList; 
    pcMaxSlots : Cardinal; 
    ppv : IObjectArray; 
    poa : IObjectCollection; 
    LTask : IShellLink; 
    LPropertyStore : IPropertyStore; 
    LTitle : TPropVariant; 
    LTaskBarList : ITaskBarList; 
    LTaskBarList3 : ITaskBarList3; 
    hr : HRESULT; 
begin 
    LTaskBarList := CreateComObject(CLSID_TaskBarList) as ITaskBarList; 
    hr := LTaskBarList.QueryInterface(IID_ITaskBarList3, LTaskBarList3); 
    if hr <> S_OK then exit; 


    LCustomDestinationList := CreateComObject(CLSID_DestinationList) as ICustomDestinationList; 
    LCustomDestinationList.BeginList(pcMaxSlots, IID_IObjectArray, ppv); 
    poa := CreateComObject(CLSID_EnumerableObjectCollection) as IObjectCollection; 


    LTask := CreateComObject(CLSID_ShellLink) as IShellLink; 
    LTask.SetPath(pChar(ParamStr(0))); //set the path to the exe 
    LTask.SetDescription('This is a description sample'); 
    LTask.SetArguments(PChar('Bar')); 
    LTask.SetIconLocation(PChar('Shell32.dll'),1); 
    LPropertyStore := LTask as IPropertyStore; 
    LTitle.vt := VT_LPWSTR; 
    LTitle.pwszVal := PChar('This is the Task 1'); 
    LPropertyStore.SetValue(PKEY_Title,LTitle); 
    LPropertyStore.Commit; 
    poa.AddObject(LTask); 

    LTask := CreateComObject(CLSID_ShellLink) as IShellLink; 
    LTask.SetPath(PChar(ParamStr(0))); //set the path to the exe 
    LTask.SetDescription('This is a description sample'); 
    LTask.SetArguments(PChar('Foo')); 
    LTask.SetIconLocation(pChar('Shell32.dll'),1); 
    LPropertyStore := LTask as IPropertyStore; 
    LTitle.vt := VT_LPWSTR; 
    LTitle.pwszVal := pChar('This is the Task 2'); 
    LPropertyStore.SetValue(PKEY_Title,LTitle); 
    LPropertyStore.Commit; 
    poa.AddObject(LTask); 


    LCustomDestinationList.AddUserTasks(poa as IObjectArray); 
    LCustomDestinationList.CommitList; 
end; 

begin 
try 
    CoInitialize(nil); 
    try 
     CreateTaskList; 
    finally 
     CoUninitialize; 
    end; 
except 
    on E:EOleException do 
     Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode])); 
    on E:Exception do 
     Writeln(E.Classname, ':', E.Message); 
end; 
Writeln('Press Enter to exit'); 
Readln; 
end. 

enter image description here

+0

hay un buen ejemplo de cómo hacer esto en C# [aquí ] (http://www.canofcode.co.uk/software/how-to-add-jumplists-to-ac-application/). – nateirvin

Cuestiones relacionadas