📄 67.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://bbs.tsinghua.edu.cn"><font face="黑体"><big><big>水木清华★</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center"> Delphi编程 (BM: strayli FlyingBoy) </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="454"> <p align="center">[<a href="index.htm">回到开始</a>][<a href="13.htm">上一层</a>][<a href="68.htm">下一篇</a>]
<hr><p align="left"><small>发信人: strayli (stray), 信区: Delphi <br>
标 题: How to write Delphi wizard(3) <br>
发信站: BBS 水木清华站 (Thu Nov 5 22:02:23 1998) WWW-POST <br>
<br>
returns True if the named file is currently open. <br>
GetNewModuleName <br>
Automatically generates a valid Filename and Unit identifier. Uses the same <br>
mechanism as used by the IDE. <br>
Component library interface <br>
<br>
GetModuleCount <br>
Returns the number of currently installed modules in the component library. <br>
GetModuleName <br>
Returns then name of the module given its index. <br>
GetComponentCount <br>
Returns the number of components installed in a particular module. <br>
GetComponentName <br>
Returns the name of the component given its module index and index in that <br>
module. <br>
Error handling <br>
<br>
RaiseException <br>
This will cause an Exception to be raised with the IDE with the string passed <br>
to this function. NOTE: This will cause the stack to unwind and control will <br>
NOT return to this point. It is the resposibility of the Library to be sure <br>
it has correctly handled the error condition before calling this procedure. <br>
TIToolInterface for Delphi 2.0x and 3 <br>
Delphi 2.0x and 3 have an expanded Open Tools API (compared to Delphi 1.x), <br>
which is not only reflected in a few new methods for TIExpert, but especially <br>
for TIToolServices. The following additional methods are new and for the <br>
32-bits versions of Delphi only (methods that are shared with Delphi 1.0 have <br>
been left out for now): <br>
<br>
<br>
TIToolServices = class(TInterface) <br>
public <br>
{ Action interfaces } <br>
function CreateModuleEx(const ModuleName, FormName, AncestorClass, <br>
FileSystem: string; Source, Form: TIStream; <br>
CreateFlags: TCreateModuleFlags): TIModuleInterface; virtual; <br>
stdcall; abstract; <br>
<br>
{ Project/UI information } <br>
function EnumProjectUnits(EnumProc: TProjectEnumProc; Param: Pointer): <br>
Boolean; <br>
Boolean; <br>
virtual; stdcall; abstract; <br>
<br>
{ Virtual File system interfaces } <br>
function RegisterFileSystem(AVirtualFileSystem: TIVirtualFileSystem): <br>
Boolean; <br>
virtual; stdcall; abstract; <br>
function UnRegisterFileSystem(const Ident: string): Boolean; virtual; <br>
stdcall; abstract; <br>
function GetFileSystem(const Ident: string): TIVirtualFileSystem; virtual; <br>
stdcall; abstract; <br>
<br>
{ Editor Interfaces } <br>
function GetModuleInterface(const FileName: string): TIModuleInterface; <br>
virtual; stdcall; abstract; <br>
function GetFormModuleInterface(const FormName: string): TIModuleInterface; <br>
<br>
virtual; stdcall; abstract; <br>
<br>
{ Menu Interfaces } <br>
function GetMainMenu: TIMainMenuIntf; virtual; stdcall; abstract; <br>
<br>
{ Notification registration } <br>
function AddNotifier(AddInNotifier: TIAddInNotifier): Boolean; <br>
virtual; stdcall; abstract; <br>
function RemoveNotifier(AddInNotifier: TIAddInNotifier): Boolean; <br>
virtual; stdcall; abstract; <br>
<br>
{ Pascal string handling functions } <br>
function NewPascalString(Str: PChar): Pointer; virtual; stdcall; abstract; <br>
procedure FreePascalString(var Str: Pointer); virtual; stdcall; abstract; <br>
procedure ReferencePascalString(var Str: Pointer); virtual; stdcall; <br>
abstract; <br>
procedure AssignPascalString(var Dest, Src: Pointer); virtual; <br>
stdcall; abstract; <br>
<br>
{ Configuration Access } <br>
function GetBaseRegistryKey: string; virtual; stdcall; abstract; <br>
end; <br>
<br>
The following ToolServices functions are available to the client for 32-bits <br>
versions of Delphi only: <br>
Actions <br>
CreateModuleEx <br>
New extended form of CreateModule. This will return a TIModuleInterface. All <br>
return a TIModuleInterface. All <br>
CreateModes from CreateModule are supported with only the following <br>
differences: <br>
cmExisting: Will create an existing module from the given file system. <br>
AncestorClass: This must specify an existing base class in the project. (use <br>
the cmAddToProject flag to add a module to the project first). <br>
Informational <br>
<br>
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>
in 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>
ctions, 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>
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>
, 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>
<br>
<br>
<br>
-- <br>
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 159.226.64.144] <br>
</small><hr>
<p align="center">[<a href="index.htm">回到开始</a>][<a href="13.htm">上一层</a>][<a href="68.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -