首页  编辑  

查找计算机对话框

Tags: /超级猛料/VCL/Common.Dialog.通用对话框和控件/   Date Created:

function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;

stdcall; external 'Shell32.dll' index 90;

function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;

stdcall; external 'Shell32.dll' index 91;

*******************

//用的是98,不知道95上行不行。

unit RunDialog;

{**********************************************************}

{                                                          }

{  TRunDialog Unit                                         }

{  Copyright ?999 Workshell Software.                     }

{                                                           }

{  Version 1.0                                                   }

{                                                          }

{                                                          }

{  Web      -> http://www.workshell.uni.cc/                }

{  E - Mail -> rundlg@kinsella.u-net.com                   }

{                                                          }

{**********************************************************}

interface

uses

 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type

 TRunDialog = class(TComponent)

 private

   { Private declarations }

   FDescription: String;

   FHideBrowseButton: Boolean;

   FIcon: TIcon;

   FInitialDir: String;

   FTitle: String;

   procedure SetDescription(Value: String);

   procedure SetHideBrowseButton(Value: Boolean);

   procedure SetIcon(Value: TIcon);

   procedure SetInitialDir(Value: String);

   procedure SetTitle(Value: String);

 protected

   { Protected declarations }

   constructor Create(AOwner: TComponent); override;

   destructor Destroy; override;

 public

   { Public declarations }

   procedure Execute;

 published

   { Published declarations }

   property Description: String read FDescription write SetDescription;

   property HideBrowseButton: Boolean read FHideBrowseButton write SetHideBrowseButton;

   property Icon: TIcon read FIcon write SetIcon;

   property InitialDir: String read FInitialDir write SetInitialDir;

   property Title: String read FTitle write SetTitle;

 end;

var

Flags: LongInt = 0;

const

RFF_NOBROWSE = 1;

procedure Register;

implementation

procedure RunFileDlgA(OwnerWnd: HWND; Icon: HICON; lpstrDirectory: PAnsiChar;

lpstrTitle: PAnsiChar; lpstrDescription: PAnsiChar; Flags: LongInt); stdcall;

external 'Shell32.dll' index 61;

constructor TRunDialog.Create(AOwner: TComponent);

begin

inherited Create(AOwner);

FIcon := TIcon.Create;

end;

destructor TRunDialog.Destroy;

begin

FIcon.Free;

inherited Destroy;

end;

procedure TRunDialog.Execute;

begin

if FHideBrowseButton = True then

begin

 Flags := Flags or RFF_NOBROWSE;

end;

RunFileDlgA(0,FIcon.Handle,PChar(FInitialDir),PChar(FTitle),PChar(FDescription),Flags);

end;

procedure TRunDialog.SetDescription(Value: String);

begin

if Value <> FDescription then

begin

 FDescription := Value;

end;

end;

procedure TRunDialog.SetHideBrowseButton(Value: Boolean);

begin

if Value <> FHideBrowseButton then

begin

 FHideBrowseButton := Value;

end;

end;

procedure TRunDialog.SetIcon(Value: TIcon);

begin

if Value <> FIcon then

begin

 FIcon.Assign(Value);

end;

end;

procedure TRunDialog.SetInitialDir(Value: String);

begin

if Value <> FInitialDir then

begin

 FInitialDir := Value;

end;

end;

procedure TRunDialog.SetTitle(Value: String);

begin

if Value <> FTitle then

begin

 FTitle := Value;

end;

end;

procedure Register;

begin

 RegisterComponents('Dialogs', [TRunDialog]);

end;

end.

unit FindDialogs;

{**********************************************************}

{                                                          }

{  TFindFilesDialog & TFindComputerDialog Unit             }

{  Copyright ?999 Workshell Software.                     }

{                                                           }

{  Version 1.0                                                   }

{                                                          }

{                                                          }

{  Web      -> http://www.workshell.uni.cc/                }

{  E - Mail -> finddlgs@kinsella.u-net.com                 }

{                                                          }

{**********************************************************}

interface

uses

 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

 ShlObj;

type

 TFindFilesDialog = class(TComponent)

 private

   { Private declarations }

 protected

   { Protected declarations }

 public

   { Public declarations }

   function Execute: Boolean;

   function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;

 published

   { Published declarations }

 end;

type

 TFindComputerDialog = class(TComponent)

 private

   { Private declarations }

 protected

   { Protected declarations }

 public

   { Public declarations }

   function Execute: Boolean;

   function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;

 published

   { Published declarations }

 end;

procedure Register;

implementation

function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;

stdcall; external 'Shell32.dll' index 90;

function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;

stdcall; external 'Shell32.dll' index 91;

function TFindFilesDialog.Execute: Boolean;

begin

Result := SHFindFiles(nil,nil);

end;

function TFindFilesDialog.ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;

begin

Result := SHFindFiles(pidlRoot,pidlSavedSearch);

end;

function TFindComputerDialog.Execute: Boolean;

begin

Result := SHFindComputer(nil,nil);

end;

function TFindComputerDialog.ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;

begin

Result := SHFindComputer(pidlRoot,pidlSavedSearch);

end;

procedure Register;

begin

 RegisterComponents('Dialogs', [TFindFilesDialog,TFindComputerDialog]);

end;

end.