我想要做一个象Windows2000的打开对话框一样的OpenDialog但是Windows2000打开对话框

Linux2001 2001-12-05 04:26:23
我想要做一个象Windows2000的打开对话框一样的OpenDialog但是Windows2000打开对话框左边那些什么我的电脑,我的文档,网上邻居之类的是如何实现的啊
...全文
87 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luo73 2002-01-31
  • 打赏
  • 举报
回复
看一看下面的代码,引用 Win2K/XP 'comdlg32.dll'中的函数!

********************************************************)

unit AgOpenDialog;
interface

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

type
TAgOpenDialog = class(TOpenDialog)
private
{ Private declarations }
protected
{ Protected declarations }
FShowPlacesBar : boolean;
FInterceptor : Pointer;
function IsWin2000 : boolean;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
function Execute: Boolean; override;
published
{ Published declarations }
property ShowPlacesBar : boolean read FShowPlacesBar write FShowPlacesBar;
end;

TAgSaveDialog = class(TAgOpenDialog)
public
constructor Create(AOwner: TComponent); override;
end;


procedure Register;

type
TOpenFileNameEx = packed record
lStructSize: DWORD;
hWndOwner: HWND;
hInstance: HINST;
lpstrFilter: PAnsiChar;
lpstrCustomFilter: PAnsiChar;
nMaxCustFilter: DWORD;
nFilterIndex: DWORD;
lpstrFile: PAnsiChar;
nMaxFile: DWORD;
lpstrFileTitle: PAnsiChar;
nMaxFileTitle: DWORD;
lpstrInitialDir: PAnsiChar;
lpstrTitle: PAnsiChar;
Flags: DWORD;
nFileOffset: Word;
nFileExtension: Word;
lpstrDefExt: PAnsiChar;
lCustData: LPARAM;
lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
lpTemplateName: PAnsiChar;
pvReserved : Pointer;
dwReserved : DWORD;
FlagsEx : DWORD;
end;

function GetOpenFileNameEx(var OpenFile: TOpenFilenameEx): Bool; stdcall;
function GetSaveFileNameEx(var OpenFile: TOpenFilenameEx): Bool; stdcall;
implementation

{$R *.RES}

function GetOpenFileNameEx; external 'comdlg32.dll' name 'GetOpenFileNameA';
function GetSaveFileNameEx; external 'comdlg32.dll' name 'GetSaveFileNameA';

procedure Register;
begin
RegisterComponents('Samples', [TAgOpenDialog, TAgSaveDialog]);
end;

var
CurInstanceShowPlacesBar : boolean;
function OpenInterceptor(var DialogData: TOpenFileName): Bool; stdcall;
var DialogDataEx : TOpenFileNameEx;
begin
Move(DialogData, DialogDataEx, sizeof(DialogDataEx));
if CurInstanceShowPlacesBar then
DialogDataEx.FlagsEx := 0
else
DialogDataEx.FlagsEx := 1;
DialogDataEx.lStructSize := sizeof(TOpenFileNameEx);
Result := GetOpenFileNameEx( DialogDataEx );
end;

function SaveInterceptor(var DialogData: TOpenFileName): Bool; stdcall;
var DialogDataEx : TOpenFileNameEx;
begin
Move(DialogData, DialogDataEx, sizeof(DialogDataEx));
if CurInstanceShowPlacesBar then
DialogDataEx.FlagsEx := 0
else
DialogDataEx.FlagsEx := 1;
DialogDataEx.lStructSize := sizeof(TOpenFileNameEx);
Result := GetSaveFileNameEx( DialogDataEx );
end;

{ TAgOpenDialog }

constructor TAgOpenDialog.Create(AOwner: TComponent);
begin
inherited;
FShowPlacesBar := TRUE;
FInterceptor := @OpenInterceptor;
end;

function TAgOpenDialog.Execute: Boolean;
var Inst : Pointer;
begin
if IsWin2000 then
begin
CurInstanceShowPlacesBar := FShowPlacesBar;
Result := DoExecute(FInterceptor);
end
else
Result := inherited Execute;
end;

function TAgOpenDialog.IsWin2000: boolean;
var ver : TOSVersionInfo;
begin
Result := FALSE;
ver.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not GetVersionEx(ver ) then
Exit;

if (ver.dwPlatformId=VER_PLATFORM_WIN32_NT) then
begin
// Test for the product.
if ( ver.dwMajorVersion >= 4 ) then
Result := TRUE;
end;
end;


{ TAgSaveDialog }

constructor TAgSaveDialog.Create(AOwner: TComponent);
begin
inherited;
FInterceptor := @SaveInterceptor;
end;

end.
Linux2001 2001-12-07
  • 打赏
  • 举报
回复
好象可以哦,试一试啊
thedream 2001-12-06
  • 打赏
  • 举报
回复
自己做form,左边那些用按钮
根据那些按狃的onclick,改变combobox和listview的内容
thedream 2001-12-06
  • 打赏
  • 举报
回复
自己做form,左边那些用按钮
根据那些按狃的onclick,改变combobox和listview的内容

Linux2001 2001-12-06
  • 打赏
  • 举报
回复
没有人了吗,5555555555555555555
Linux2001 2001-12-05
  • 打赏
  • 举报
回复
但是我认为自己做比较好用
cobi 2001-12-05
  • 打赏
  • 举报
回复
使用特定的控件吧
ahdou0 2001-12-05
  • 打赏
  • 举报
回复
你何必要自己做了?看看www.51delphi.com中的控件,里面有现成的控件.delphi的特点就是
开发效率高,如果什么都自己做,且不是累死人?

5,928

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧