How to get a new module name from the Delphi open tools API

I wrote a wizard in Delphi XE and it works fine. However, I have not yet figured out how to access the generated unit name by default (or form name or project name) that Delphi OTA can create.

In my old-style wizard, I was able to call ToolServices.GetNewModuleName to find the available unit and form name that I could use when creating the associated source files. What is equivalent in the open tools API today?

According to the comments of the ToolsAPI module, I have to return an empty value from the IOTAModuleCreator.GetImplFileName method so that Delphi will generate the file name. I am returning an empty string from this method, but still cannot see where I can access the file name that Delphi generates.

+6
delphi delphi-xe wizard
source share
3 answers

There is a special method for obtaining a new form and unit name:

(BorlandIDEServices as IOTAModuleServices) .GetNewModuleAndClassName ('', UnitIdent, FormName, FileName);

I used in a few examples and it seems to work fine.

+4
source share

The IOTAModuleCreator.NewImplSource method has a parameter ModuleIdent, this is the name of the unit.

+2
source share

In my tests, it works as you expected (the ModuleIdent parameter in the ModuleIdent method gets the name of the new device). Check your implementation again, especially make sure that:

  • IOTACreator.GetUnnamed returns True
  • IOTACreator.GetExisting returns False
  • IOTACreator.GetCreatorType returns the corresponding identifier ( sUnit , sForm , etc.). I'm not sure about this, but it can be important.

Here is a working example. I just checked it and the code still works as expected in Delphi XE.

+2
source share

All Articles