📄 controlproptyedit.pas
字号:
unit ControlProptyEdit;
interface
uses
Windows, Messages, SysUtils,Forms , Classes,DsgnIntf,shlObj;
procedure Register;
implementation
uses ExportConnection,dbclient,Controls,ReportData;
{ TComputerNameProperty }
type
THostProperty = class(TStringProperty)
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
function THostProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
procedure THostProperty.Edit;
var
BrowseInfo: TBrowseInfo;
ItemIDList: PItemIDList;
ComputerName: array[0..MAX_PATH] of Char;
Title: string;
WindowList: Pointer;
Result: Boolean;
begin
if Failed(SHGetSpecialFolderLocation(Application.Handle, CSIDL_NETWORK, ItemIDList)) then
raise Exception.Create('错误!');
FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
BrowseInfo.hwndOwner := Application.Handle;
BrowseInfo.pidlRoot := ItemIDList;
BrowseInfo.pszDisplayName := ComputerName;
Title := '选择服务器地址';
BrowseInfo.lpszTitle := PChar(Pointer(Title));
BrowseInfo.ulFlags := BIF_BROWSEFORCOMPUTER;
WindowList := DisableTaskWindows(0);
try
Result := SHBrowseForFolder(BrowseInfo) <> nil;
finally
EnableTaskWindows(WindowList);
end;
if Result then SetValue(ComputerName);
end;
{ TServeProperty }
type
TServeProperty = class(TStringProperty)
function AutoFill: Boolean; override;
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;
function TServeProperty.AutoFill: Boolean;
begin
Result := False;
end;
function TServeProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paValueList, paSortList];
end;
type
TConnectionAccess = class(TCustomRemoteServer);
procedure TServeProperty.GetValues(Proc: TGetStrProc);
var
Connection: TConnectionAccess;
Data: OleVariant;
i: Integer;
begin
Screen.Cursor := crHourGlass;
try
Connection := TConnectionAccess(PubReportData.ReportConnect);
Data := Connection.GetServerList;
if VarIsArray(Data) then
for i := 0 to VarArrayHighBound(Data, 1) do
Proc(Data[i]);
finally
Screen.Cursor := crDefault;
end;
end;
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(string), TExportConnection, 'Host', THostProperty);
RegisterPropertyEditor(TypeInfo(string), TExportConnection, 'ServerName', TServeProperty);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -