SetIncludeExclude (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example demonstrates the use of the Include and Exclude routines. The example assumes a form with three check boxes and a button. Also, a field called FMsgButtons, of type TMsgDlgButtons is declared in the form.

Code

procedure TOptionsForm.btShowMessageClick(Sender: TObject);
begin
  //Creates a Message Dialog with the Selected Buttons.
  MessageDlg('Hello World!', mtInformation, FMsgButtons, 0);
end;

procedure TOptionsForm.CheckBoxClick(Sender: TObject);
begin
  { Check wether an option is selected and add an element into a set,
    or exclude it from the set. }

  if cbYes.Checked then
    Include(FMsgButtons, mbYes)
  else
    Exclude(FMsgButtons, mbYes);

  if cbNo.Checked then
    Include(FMsgButtons, mbNo)
  else
    Exclude(FMsgButtons, mbNo);

  if cbCancel.Checked then
    Include(FMsgButtons, mbCancel)
  else
    Exclude(FMsgButtons, mbCancel);
end;

Uses