سؤال

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

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

According to the ToolsAPI unit comments, I should return a blank from the IOTAModuleCreator.GetImplFileName method to have Delphi 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 is generating.

هل كانت مفيدة؟

المحلول

There is a specific method for getting a new form and unit name:

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

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

نصائح أخرى

The method IOTAModuleCreator.NewImplSource have a "ModuleIdent" parametter, it is the unit name.

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

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

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top