MessageDlg'de Case of Kullanımı!

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
Guybrush
Üye
Mesajlar: 15
Kayıt: 24 Kas 2005 04:13
Konum: İzmir

MessageDlg'de Case of Kullanımı!

Mesaj gönderen Guybrush »

Elimde şöyle bir kod parçası var;

If MessageDlg('Hangi Tuşa Basıldı',mtinformation,[mbYes,mbNo,mbCancel],0);

Case a of
mrYes: showmessage('Yes Tuşuna Bastınız');
mrNo: showmessage('No Tuşuna Bastınız') else

showmessage('Cancel Tuşuna Bastınız');
end;//case

Bunu buttonClick olayına yazıcam. Sorum şu:
Burda a değişkenini ne şekilde tanımlamam gerekir, ve tipi ne olsun? Boolean olabilir mi?

Bilgisayar bölümünde okuyorum ve üç gün sonra Delphi'den vizem var. Yardımcı oluranız sevinirim....
Kullanıcı avatarı
webaytek
Üye
Mesajlar: 377
Kayıt: 23 Haz 2004 10:58

Mesaj gönderen webaytek »

function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Word;

Description

Call MessageDlg to bring up a message box and obtain the user's response. The message box displays the value of the Msg parameter. Use the DlgType parameter to indicate the purpose of the dialog. Use the Buttons parameter to indicate what buttons should appear in the message box. Use the HelpCtx parameter to specify the context ID for the help topic that should appear when the user clicks the help button or presses F1 while the dialog is displayed.

MessageDlg returns the value of the button the user selected. These are the possible return values:

Return values

mrNone mrAbort mrYes
mrOk mrRetry mrNo
mrCancel mrIgnore mrAll
bu delphi helpten > MessageDlg yazınca çıkan sonuç > bu da istediğiniz bölüm. | Buttons: TMsgDlgButtons; >>>>
TMsgDlgButtons defines a set of values used by MessageDlg and MessageDlgPos.

Unit

Dialogs

type

TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mnNoToAll, mbYesToAll, mbHelp);

const

mbYesNoCancel = [mbYes, mbNo, mbCancel];
mbOKCancel = [mbOK, mbCancel];

mbAbortRetryIgnore = [mbAbort, mbRetry, mbIgnore];

TMsgDlgButtons = set of TMsgDlgBtn;

Description

The TMsgDlgButtons type defines the set of values a button in a message box can have. The TMsgDlgButtons type is used by the MessageDlg and MessageDlgPos functions. The following tables lists the possible values:

Value Meaning

mbYes A button with 'Yes' on its face.
mbNo A button the text 'No' on its face.
mbOK A button the text 'OK' on its face.
mbCancel A button with the text 'Cancel' on its face.
mbAbort A button with the text 'Abort' on its face
mbRetry A button with the text 'Retry' on its face
mbIgnore A button the text 'Ignore' on its face
mbAll A button with the text 'All' on its face

mbNoToAll A button with the text 'No to All' on its face
mbYesToAll A button with the text 'Yes to All' on its face
mbHelp A button with the text 'Help' on its face

In addition, the dialogs unit defines three constants for commonly used TMsgDlgButtons values:

Constant Meaning

mbYesNoCancel mbYes, mbNo, and mbCancel
mbOKCancel mbOK and mbCancel
mbAbortRetryIgnore mbAbort, mbRetry, and mbIgnore
diye umut ediyorum - KOLAY GELSİN
Kullanıcı avatarı
vkamadan
Kıdemli Üye
Mesajlar: 1935
Kayıt: 17 Mar 2004 03:52
Konum: Adapazarı
İletişim:

Mesaj gönderen vkamadan »

Merhaba ,

Kod: Tümünü seç

case  MessageDlg('Hangi Tuşa Basıldı',mtinformation,[mbYes,mbNo,mbCancel],0) of
   mrYes: showmessage('Yes Tuşuna Bastınız');
   mrNo: showmessage('No Tuşuna Bastınız');
 end;
şeklinde kullanmanızı öneririm, kod daha derli toplu durur.
iyi çalışmalar.
Volkan KAMADAN
www.polisoft.com.tr
ylmz
Üye
Mesajlar: 110
Kayıt: 18 Mar 2005 02:32
Konum: Antalya

Mesaj gönderen ylmz »

Kod: Tümünü seç

procedure TForm1.Button1Click(Sender: TObject);
var
  a: word;
begin
  a := MessageDlg('Hangi Tuşa Basıldı',mtinformation,[mbYes,mbNo,mbCancel],0);
  case a of
    mryes : showmessage('yes basıldı');
    mrno  : showmessage('no basıldı')
    //..
  end;
  //ya da a değişkenini hiç kullanma
  case MessageDlg('Hangi Tuşa Basıldı',mtinformation,[mbYes,mbNo,mbCancel],0) of
    mryes : showmessage('yes basıldı');
    mrno  : showmessage('no basıldı')
    //..
  end;
end;
Cevapla