To obtain a module interface, start with the module services (IOTAModuleServices). You can query the module services for all open modules, look up a module from a file name or form name, or open a file to obtain its module interface.
There are different kinds of modules for different kinds of files, such as projects, resources, and type libraries. Cast a module interface to a specific kind of module interface to learn whether the module is of that type. For example, one way to obtain the current project group interface is as follows:
{ Return the current project group, or nil if there is no project group. } function CurrentProjectGroup: IOTAProjectGroup; var I: Integer; Svc: IOTAModuleServices; Module: IOTAModule; begin Supports(BorlandIDEServices, IOTAModuleServices, Svc); for I := 0 to Svc.ModuleCount - 1 do begin Module := Svc.Modules[I]; if Supports(Module, IOTAProjectGroup, Result) then Exit; end; Result := nil; end;
// Return the current project group, or 0 if there is no project group. _di_IOTAProjectGroup __fastcall CurrentProjectGroup() { _di_IOTAModuleServices svc; BorlandIDEServices->Supports(svc); for (int i = 0; i < svc->ModuleCount; ++i) { _di_IOTAModule module = svc->Modules[i]; _di_IOTAProjectGroup group; if (module->Supports(group)) return group; } return 0; }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|