01-01-2014, 11:43 AM
01-01-2014, 02:45 PM
وعليكم السلام ورحمة الله وبركاته .
أه .. لقد ذكرتني بموضوع كنت **** أن أكتبه و أنشره في المنتدى منذ زمن , لكن ظروفي و هموم الحياة منعتني من ذلك ..
على كل حال , لتطبيق الفكرة يجب أن يتوفر شرطين :
[COLOR="Red"]-نسخة دلفي >= 2009 .
- نظام >= vista .[/COLOR]
يمكن تطبيق الفكرة باستخدام ال interface : IFileDialogCustomize .
كخطوة أولى الحصول على IFileDialogCustomize من خلال Dialog.QueryInterface ..
ثم اضافة المكونات الى OpenDialog ..
المكونات المدعومة :
ثم تأتي المرحلة الثانية : اقتماص الأحداث عن طريق ال interface IFileDialogControlEvents ..
------------------------------------
هذا مثال بسيط :
![[صورة: iGxcm.png]](http://im31.gulfup.com/iGxcm.png)
أه .. لقد ذكرتني بموضوع كنت **** أن أكتبه و أنشره في المنتدى منذ زمن , لكن ظروفي و هموم الحياة منعتني من ذلك ..
على كل حال , لتطبيق الفكرة يجب أن يتوفر شرطين :
[COLOR="Red"]-نسخة دلفي >= 2009 .
- نظام >= vista .[/COLOR]
يمكن تطبيق الفكرة باستخدام ال interface : IFileDialogCustomize .
كخطوة أولى الحصول على IFileDialogCustomize من خلال Dialog.QueryInterface ..
ثم اضافة المكونات الى OpenDialog ..
المكونات المدعومة :
كود :
Menu
PushButton
ComboBox
RadioButtonList
CheckButton
EditBox
Separator
Text
Groupثم تأتي المرحلة الثانية : اقتماص الأحداث عن طريق ال interface IFileDialogControlEvents ..
------------------------------------
هذا مثال بسيط :
PHP كود :
unit uMyFileOpenDialog;
{ ====> By SMP3 <==== }
interface
uses
System.SysUtils,
System.Classes,
Winapi.Windows,
Winapi.Messages,
Winapi.ShlObj,
Vcl.Dialogs;
type
TMyFileOpenDialogEvents = class(TInterfacedObject, IFileDialogEvents,
IFileDialogControlEvents)
{ IFileDialogEvents Proc }
function OnFileOk(const pfd: IFileDialog): HResult; stdcall;
function OnFolderChanging(const pfd: IFileDialog;
const psiFolder: IShellItem): HResult; stdcall;
function OnFolderChange(const pfd: IFileDialog): HResult; stdcall;
function OnSelectionChange(const pfd: IFileDialog): HResult; stdcall;
function OnShareViolation(const pfd: IFileDialog; const psi: IShellItem;
out pResponse: DWORD): HResult; stdcall;
function OnTypeChange(const pfd: IFileDialog): HResult; stdcall;
function OnOverwrite(const pfd: IFileDialog; const psi: IShellItem;
out pResponse: DWORD): HResult; stdcall;
{ IFileDialogControlEvents Proc }
function OnItemSelected(const pfdc: IFileDialogCustomize; dwIDCtl: DWORD;
dwIDItem: DWORD): HResult; stdcall;
function OnButtonClicked(const pfdc: IFileDialogCustomize; dwIDCtl: DWORD)
: HResult; stdcall;
function OnCheckButtonToggled(const pfdc: IFileDialogCustomize;
dwIDCtl: DWORD; bChecked: BOOL): HResult; stdcall;
function OnControlActivating(const pfdc: IFileDialogCustomize;
dwIDCtl: DWORD): HResult; stdcall;
end;
TMyFileOpenDialog = class(TFileOpenDialog)
private
FDialogEvents: IFileDialogEvents;
FEvents: TMyFileOpenDialogEvents;
FInitDialog: Boolean;
FCookie: DWORD;
protected
function Execute(ParentWnd: HWND): Boolean; overload; virtual;
function GetResults: HResult; virtual;
procedure DoOnExecute; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
const
D4ABtnID = 1;
{ TMyFileOpenDialog }
constructor TMyFileOpenDialog.Create(AOwner: TComponent);
begin
inherited;
FEvents := nil;
FInitDialog := False;
end;
destructor TMyFileOpenDialog.Destroy;
begin
inherited;
end;
procedure TMyFileOpenDialog.DoOnExecute;
var
MyCustDlg: IFileDialogCustomize;
begin
inherited;
if Dialog.QueryInterface(IFileDialogCustomize, MyCustDlg) = S_OK then
with MyCustDlg do
begin
StartVisualGroup(0, 'My Group');
AddPushButton(D4ABtnID, 'Delphi4Arab');
EndVisualGroup;
MakeProminent(0);
FEvents := TMyFileOpenDialogEvents.Create;
FEvents.QueryInterface(IFileDialogEvents, FDialogEvents);
Dialog.Advise(FDialogEvents, FCookie);
FInitDialog := True;
end;
end;
function TMyFileOpenDialog.Execute(ParentWnd: HWND): Boolean;
begin
inherited;
if FInitDialog then
Dialog.Unadvise(FCookie);
end;
function TMyFileOpenDialog.GetResults: HResult;
begin
inherited;
end;
{ TMyFileOpenDialogEvents }
function TMyFileOpenDialogEvents.OnButtonClicked
(const pfdc: IFileDialogCustomize; dwIDCtl: DWORD): HResult;
begin
if dwIDCtl = D4ABtnID then
begin
// Button Clicked .
ShowMessage('Delphi4Arab');
end;
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnCheckButtonToggled
(const pfdc: IFileDialogCustomize; dwIDCtl: DWORD; bChecked: BOOL): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnControlActivating
(const pfdc: IFileDialogCustomize; dwIDCtl: DWORD): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnFileOk(const pfd: IFileDialog): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnFolderChange(const pfd: IFileDialog)
: HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnFolderChanging(const pfd: IFileDialog;
const psiFolder: IShellItem): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnItemSelected
(const pfdc: IFileDialogCustomize; dwIDCtl, dwIDItem: DWORD): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnOverwrite(const pfd: IFileDialog;
const psi: IShellItem; out pResponse: DWORD): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnSelectionChange
(const pfd: IFileDialog): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnShareViolation(const pfd: IFileDialog;
const psi: IShellItem; out pResponse: DWORD): HResult;
begin
Result := S_OK;
end;
function TMyFileOpenDialogEvents.OnTypeChange(const pfd: IFileDialog): HResult;
begin
Result := S_OK;
end;
end.
كود :
var
Op: TMyFileOpenDialog;
begin
Op := TMyFileOpenDialog.Create(nil);
Op.Execute;
Op.Free;
end;![[صورة: iGxcm.png]](http://im31.gulfup.com/iGxcm.png)
01-01-2014, 07:34 PM
جميل جدا
ولكني استخدم دلفي 7
فكيف يتم ذالك ؟
و شكرا لك
ولكني استخدم دلفي 7
فكيف يتم ذالك ؟
و شكرا لك
01-01-2014, 11:44 PM
Anew كتب :جميل جدا
ولكني استخدم دلفي 7
فكيف يتم ذالك ؟
و شكرا لك
ال IFileDialogCustomize غير مدعومة في دلفي .. بالأحرى غير موجودة ..
ستحتاج الى تظمين ال interface .. لكني لست متأكدا من أنها ستعمل على دلفي 7 (أغلب السبب راجع لليونيكود ) .