老兄,我也在问这个问题,指教你是如何得到HMENU hMenu,indexMenu,
idCmdFirst,idCmdLast,uFlags,这几个参数的?

解决方案 »

  1.   

    怎么会看不过啊??
    function TContextMenu.QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst,
              idCmdLast, uFlags: UINT): HResult;
    var asubmenu:integer;
    begin
      FMenuIdx := indexMenu;
    //  if ((uFlags and $0000000F) = CMF_NORMAL) or
      //   ((uFlags and CMF_EXPLORE) <> 0) then begin
        asubmenu:=CreateMenu;//CreatePopupMenu;这句创建了要不要释放?
    //子菜单
        InsertMenu(asubmenu,FMenuIdx,MF_BYPOSITION or MF_STRING, idcmdfirst+1,'子菜单1');
        InsertMenu(asubmenu,FMenuIdx,MF_BYPOSITION or MF_STRING, idcmdfirst+2,'子菜单2');
    //插入子菜单
        InsertMenu(menu, FMenuIdx,MF_BYPOSITION or MF_STRING or MF_Popup , asubmenu,'菜单1');
        InsertMenu(menu, FMenuIdx,MF_BYPOSITION or MF_STRING ,idcmdfirst,'菜单2');
    //    DestroyMenu(asubmenu);
        Result := 4;//FMenuIdx + 1;
    end;
    然后编译DLL文件后,注册下,右键菜单弹出来没有问题
    问题出在按菜单中的文件,按几次,菜单1就增加几个?他怎么不会自动FREE
    是不是要控制uFlags来区别是单击菜单中的文件还是右键单击?