delphi4arab منتديات دلفي للعرب

نسخة كاملة : كيف عند الضغط للخروج من البرنامج تطلب التاكييد ؟
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم

كيف عند الضغط للخروج من البرنامج تطلب التاكييد ؟
كود :
http://www8.0zz0.com/2012/03/31/16/806116784.png
وعليكم السلام
اولا لطلب التاكيد استعمل MessageDlg
PHP كود :
procedure TForm1.Button1Click(Sender: TObject);
begin
if MessageDlg('هل انت متاكد من رغبتك في الخروج',mtInformation,[mbYes,mbNo],0)=mryes then
Close
;
end; 
اما فيما يخص الامر الاخر وضح اكثر
[INDENT]
وعليكم السلام ورحمة الله وبركاته ، و لماذا تنشىء نافذة جديدة ؟
عندك الحدث OnCloseQuery التابع للفورم الرئسي ضع فيه هذا الكود :

كود :
if messagedlg('Quitter le logiciel ? ',mtconfirmation,[mbYes,mbNo],0) = mrNo then canclose := false

أي بمعنى انك تتحكم في قيمة canclose

وفقك الباري لكل خير.
[/INDENT]
لا ليس بـــ messagedlg بلا بفورم

تم الحل
كود :
procedure Ttable.FormCloseQuery(Sender: TObject; var CanClose: Boolean); var selected:integer; begin selected:= Form6.ShowModal; if selected=mrOk then begin CanClose:=true; end; if selected=mrCancel then begin CanClose:=False; end; end;
Unit1
كود :
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Unit2, StdCtrls; type TForm1 = class(TForm) procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Actions: TCloseAction; implementation {$R *.dfm} procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Form2.ShowModal; Action := Actions; end; end.
Unit2
كود :
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} uses Unit1; procedure TForm2.Button1Click(Sender: TObject); begin Actions := caHide; Close; end; procedure TForm2.Button2Click(Sender: TObject); begin Actions := caNone; Close; end; end.