Minggu, 24 Februari 2013

Example code : Display a confirmation dialog


Palebambang, 25 Februari 2013 13:00

Example code : Display a confirmation dialog
var
  buttonSelected : Integer;
begin
  // Show a confirmation dialog
  buttonSelected := MessageDlg('Confirmation',mtError, mbOKCancel, 0);

  // Show the button type selected
  if buttonSelected = mrOK     then ShowMessage('OK pressed');
  if buttonSelected = mrCancel then ShowMessage('Cancel pressed');
end;
Show full unit code
   A confirmation dialog is displayed with OK and Cancel buttons.
   The user presses OK :
  
   OK pressed
  
   is displayed in another dialog box.
 

Example code : Displays a custom dialog with custom button selection
var
  buttonSelected : Integer;
begin
  // Show a custom dialog
  buttonSelected := MessageDlg('Custom dialog',mtCustom,
                              [mbYes,mbAll,mbCancel], 0);

  // Show the button type selected
  if buttonSelected = mrYes    then ShowMessage('Yes pressed');
  if buttonSelected = mrAll    then ShowMessage('All pressed');
  if buttonSelected = mrCancel then ShowMessage('Cancel pressed');
end;
Show full unit code
   A dialog with no icon is displayed with Yes, Cancel and All buttons.
   The user presses the All button :
  
   All pressed
  
   is shown in another dialog

Tidak ada komentar:

Posting Komentar