04-13-2012، 05:25 PM
(آخرین تغییر در ارسال: 04-13-2012، 08:44 PM توسط Amin_Mansouri.)
سورس زیر برای Delphi xe2 میباشد که ساخت یک پنجره مسیج دیالوگ رو مانند تصویر زیر اموزش میدهد :
سورس کد :
سورس کد :
کد:
Firemonkey has change how you work with MessageDlgs with values and some constants so I decided to show an example how to get you started. Attached below is the source code. You can find more firemonkey examples
کد:
unit MsgDlgs;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs;
type
TMainForm = class(TForm)
YesNoBN: TButton;
OkCancelBN: TButton;
YesNoCancelBN: TButton;
AbortIgnoreBN: TButton;
YesAllNoAllCancelBN: TButton;
procedure YesNoBNClick(Sender: TObject);
procedure AbortIgnoreBNClick(Sender: TObject);
procedure OkCancelBNClick(Sender: TObject);
procedure YesNoCancelBNClick(Sender: TObject);
procedure YesAllNoAllCancelBNClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.fmx}
{
This example was coded by codecaine aka Jerome Scott II
MessageDlgs have change since prior Delphi builds and will vets.
I decided to show some examples of how they can be done in firemonkey
I tested this on Mac OS X Lion as well as Windows 7. I hope you enjoy
Here is a list of constants that can be used to to determine results and
to create custom dialogs form sets which is found in System.UITypes.
const
idOK = 1;
idCancel = 2;
idAbort = 3;
idRetry = 4;
idIgnore = 5;
idYes = 6;
idNo = 7;
idClose = 8;
idHelp = 9;
idTryAgain = 10;
idContinue = 11;
mrNone = 0;
mrOk = idOk;
mrCancel = idCancel;
mrAbort = idAbort;
mrRetry = idRetry;
mrIgnore = idIgnore;
mrYes = idYes;
mrNo = idNo;
mrClose = idClose;
mrHelp = idHelp;
mrTryAgain = idTryAgain;
mrContinue = idContinue;
mrAll = mrContinue + 1;
mrNoToAll = mrAll + 1;
mrYesToAll = mrNoToAll + 1;
}
procedure TMainForm.YesNoBNClick(Sender: TObject);
begin
if MessageDlg('hello world',TMsgDlgType.mtConfirmation,mbYesNo,0) = IDYES then
ShowMessage('Yes')
else
ShowMessage('No');
end;
procedure TMainForm.OkCancelBNClick(Sender: TObject);
begin
if MessageDlg('hello world',TMsgDlgType.mtConfirmation,mbOkCancel,0) = IDABORT then
ShowMessage('Ok')
else
ShowMessage('Cancel');
end;
procedure TMainForm.YesNoCancelBNClick(Sender: TObject);
var
value : Integer;
begin
value := MessageDlg('hello world',TMsgDlgType.mtConfirmation,mbYesNoCancel,0);
case value of
IDYES:
ShowMessage('Yes');
IDNO:
ShowMessage('No');
IDCANCEL:
ShowMessage('Cancel');
end;
end;
procedure TMainForm.AbortIgnoreBNClick(Sender: TObject);
begin
if MessageDlg('hello world',TMsgDlgType.mtConfirmation,mbAbortIgnore,0) = IDABORT then
ShowMessage('Abort')
else
ShowMessage('Ignore');
end;
procedure TMainForm.YesAllNoAllCancelBNClick(Sender: TObject);
var
value : Integer;
begin
value := MessageDlg('hello world',TMsgDlgType.mtConfirmation,mbYesAllNoAllCancel,0);
case value of
IDYES:
ShowMessage('Yes');
IDNO:
ShowMessage('No');
IDCANCEL:
ShowMessage('Cancel');
mrAll + 1 :
ShowMessage('No to all');
mrAll + 2:
ShowMessage('Yes to all');
end;
end;
end.
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg