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;
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;