📄 wizards_3.htm
字号:
EnumProjectUnits <br>
Calls EnumProc once for each unit in the project.
<br>
Editor <br>
<br>
GetModuleInterface <br>
Return an module interface associated with the given file. This function <br>
returns the same interface instance for a given module, only the reference <br>
count is adjusted. The user of this interface owns it and must call release <br>
when finished. <br>
GetFormModuleInterface <br>
returns an module interface associated with the given form.
<br>
Menu <br>
<br>
GetMainMenu <br>
Returns an interface to the IDE's main menu. See TIMainMenuIntf for details. <br>
<br>
Notification <br>
<br>
AddNotifier <br>
Registers an instance of a descendant to TIAddIn- Notifier.
<br>
RemoveNotifier <br>
Removes a registered instance of a TIAddInNotifier.
<br>
Configuration Access <br>
<br>
GetBaseRegistryKey <br>
returns a string representing the full path to Delphi's base registry key. <br>
This key is relative to HKEY_CURRENT_USER. <br>
Virtual File System <br>
<br>
The RegisterFileSystem and UnRegisterFileSystem methods seem to be present to <br>
prepare for future porting and operating/filesystem specific issues. Nice to <br>
know Borland is working on that as well! <br>
Pascal String Handling <br>
<br>
The Pascal string handling functions are provided for IDE add-in writers to <br>
use a language other than Pascal. (C or C++, for example). Add-in writers <br>
using Delphi will never need to use these functions, but we'll focus on them <br>
for the sake of completeness: <br>
NewPascalString: Allocates and returns a pascal long string from the provided <br>
PChar (char*, in C). Passing an empty string or nil for the PChar will return <br>
nil for the string (Pascal's equivalent of an empty string).
<br>
FreePascalString: Attempts to free the given Pascal string by decrementing <br>
the internal reference count and releasing the memory if the count returns to <br>
zero. <br>
ReferencePascalString: Increments the reference count of the given Pascal <br>
string. This allows the calling function to manually extend the lifetime of <br>
the string. A corresponding call to FreePascalString must be made in order to <br>
actually release the string's memory. <br>
AssignPascalString: Assigns one Pascal string to another. Never directly <br>
assign Pascal strings to each other. Doing so will orphan memory and cause a <br>
memory leak. The destination may be referencing another string, so the <br>
reference count of that string must be decremented. Likewise, the reference <br>
count of the source string must be incremented.
<br>
5. TFileOpenDialogExpert <br>
Well, with the TIToolServices class we sure have a lot of information and <br>
power at our disposal, don't we!? Let's try to do something easy that doesn't <br>
get us into trouble right away. The API that I'm looking for that will allow <br>
me to open any file as a new project seems to be OpenProject, which takes a <br>
fully qualified filename as only argument. <br>
<br>
The engine for the first version of the TFileOpenExpert is as follows:
<br>
<br>
<br>
TFileOpenExpert <br>
GetStyle: esStandard <br>
GetIDString: DrBob.TFileOpenExpert.standard <br>
GetName: FileOpen Wizard <br>
GetAuthor (win32): Bob Swart (aka Dr.Bob) <br>
GetMenuText: &FileOpen Wizard... <br>
GetState: [esEnabled] <br>
GetGlyph: 0 <br>
GetPage (win32): <br>
GetComment: <br>
<br>
So, all we need to do in the Execute procedure, is somehow get the fully <br>
qualified filename, and call ToolServices.OpenProject with it. The easiest <br>
way seems to be using a TOpenDialog, which we can create and execute on the <br>
fly, so the code of Execute looks as follows now:
<br>
<br>
<br>
procedure TFileOpenExpert.Execute; <br>
begin <br>
with TOpenDialog.Create(nil) do <br>
begin <br>
if Execute then <br>
ToolServices.OpenProject(FileName); <br>
Free <br>
end <br>
end {Execute}; <br>
<br>
Well, it's almost what we want. We forgot to initialise the filter of the <br>
TOpenDialog, so we need to do that as well. Other than that, we can indeed <br>
open up new projects, but we don't close the files of any previous projects <br>
that were loaded. So, we need to call SaveProject and CloseProject prior to <br>
calling our OpenProject. <br>
<br>
procedure TFileOpenExpert.Execute; <br>
begin <br>
with TOpenDialog.Create(nil) do <br>
begin <br>
Title := GetName; { name of Wizard as OpenDialog caption }
<br>
Filter := 'All Files (*.*)|*.*';
<br>
Options := Options + [ofShowHelp, ofPathMustExist, ofFileMustExist];
<br>
HelpContext := 0; <br>
if Execute then <br>
begin <br>
ToolServices.SaveProject; <br>
ToolServices.CloseProject; <br>
ToolServices.OpenProject(FileName) <br>
end; <br>
Free <br>
end <br>
end {Execute}; <br>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -