打印本文 打印本文 关闭窗口 关闭窗口
Delphi Open Tools Api实例研究(一)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3954  更新时间:2009/4/23 18:36:51  文章录入:mintao  责任编辑:mintao
      MenuItem[i].OnClick:=AboutForm;

     end;

   end;

   NewMenu.Add(MenuItem[i]);//添加菜单项

  end;

  FMainMenu.Items.Add(NewMenu);//最后添加我们的菜单到IDE主菜单

end;

 

procedure TNTATest.ReCodeEditer(sender:TObject);

var

 Module:IOTAModuleServices;

 CurentMoudle: IOTAModule;

 IntfEditor:IOTAEditor;

 Editor:IOTASourceEditor;

 EditView:IOTAEditView;

 EditWriterPos:IOTAEditPosition;

 i:integer;

begin

 Module:=BorlandIDEServices as IOTAModuleServices;

 CurentMoudle:=Module.CurrentModule;

 //使用IOTAModuleServices的CurrentModule方法得到当前打开的工程模块

 if CurentMoudle=nil then

 begin

  messagebox(IDEHandle,''''当前没有打开项目文件'''',''''hkTest'''',MB_ICONINFORMATION);

  exit;

 end;

 //遍历已打开工程中所有的文件

 for i:=0 to CurentMoudle.ModuleFileCount-1 do

 begin

  IntfEditor:=CurentMoudle.ModuleFileEditors[i];

  //IOTAModule的ModuleFileEditors[]属性得到一个IOTAEditor

  if IntfEditor.QueryInterface(IOTASourceEditor,Editor)=S_OK then

  //查看遍历到的文件是否是代码文件并已开始在代码编辑器中编辑。

  //如果是便通过一个out参数Editor得到一个实现IOTASourceEditor的实例

   break;

 end;

 if Editor=nil then

 begin

  messagebox(IDEHandle,''''当前没有代码编辑窗口'''',''''hkTest'''',MB_ICONINFORMATION);

上一页  [1] [2] [3] [4] [5] [6]  下一页

打印本文 打印本文 关闭窗口 关闭窗口