T
tegger
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.ToolButton1Click(Sender: TObject);
var
pt:TPoint;
ToolButton: TToolButton;
EditMenu:Hmenu;
MIndex :integer;
FOleInPlaceObject:IOleInPlaceObject;
OhWND:hWND;
iSelection:longbool;
o,o1:OleVariant;
View:IOleDocumentView;
begin
SELF.OleContainer1.OleObjectInterface.QueryInterface(IOleInPlaceObject, FOleInPlaceObject);
FOleInPlaceObject.GetWindow(OhWND);
ToolButton := Sender as TToolButton;
MIndex := ToolButton.Index;
MIndex :=1;
pt.X := ToolButton.Left;
pt.Y := ToolButton.Top+ToolButton.Height;
pt:=ToolBar1.ClientToScreen(pt);
EditMenu :=GetSubMenu(self.Menu.Handle ,MIndex);
SendMessage(OhWND,WM_INITMENUPOPUP, EditMenu,0);
iSelection:= TrackPopupMenu(EditMenu,TPM_LEFTALIGN or TPM_RETURNCMD,pt.x,pt.y,0,Handle , nil);
if(WPARAM(iSelection) >0) then
PostMessage(tHandle , WM_COMMAND, WPARAM(iSelection), 0);
end;
以上的方法能弹出Office菜单,但是执行不了菜单里的命令,不知是为什么. Office菜单问题相信困恼大家很长时间了,不知道有没有解决的办法.不知道我的思路对不对,请高人指点.
var
pt:TPoint;
ToolButton: TToolButton;
EditMenu:Hmenu;
MIndex :integer;
FOleInPlaceObject:IOleInPlaceObject;
OhWND:hWND;
iSelection:longbool;
o,o1:OleVariant;
View:IOleDocumentView;
begin
SELF.OleContainer1.OleObjectInterface.QueryInterface(IOleInPlaceObject, FOleInPlaceObject);
FOleInPlaceObject.GetWindow(OhWND);
ToolButton := Sender as TToolButton;
MIndex := ToolButton.Index;
MIndex :=1;
pt.X := ToolButton.Left;
pt.Y := ToolButton.Top+ToolButton.Height;
pt:=ToolBar1.ClientToScreen(pt);
EditMenu :=GetSubMenu(self.Menu.Handle ,MIndex);
SendMessage(OhWND,WM_INITMENUPOPUP, EditMenu,0);
iSelection:= TrackPopupMenu(EditMenu,TPM_LEFTALIGN or TPM_RETURNCMD,pt.x,pt.y,0,Handle , nil);
if(WPARAM(iSelection) >0) then
PostMessage(tHandle , WM_COMMAND, WPARAM(iSelection), 0);
end;
以上的方法能弹出Office菜单,但是执行不了菜单里的命令,不知是为什么. Office菜单问题相信困恼大家很长时间了,不知道有没有解决的办法.不知道我的思路对不对,请高人指点.