unit AdvMessageDialog;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWTypes, IWTMSCC,
  IWCompEdit, Controls, IWBaseControl, IWControl, IWCompLabel, LeftFrame,
  Forms, TopFrame, IWVCLBaseControl, IWBaseHTMLControl, IWAutoFormFill,
  IWTMSCtrls, IWAdvTreeView, IWCompListbox, AdvTreeNodes, IWCompButton, Windows,
  IWTMSCal, IWVCLBaseContainer, IWContainer, IWHTMLContainer, IWHTML40Container,
  IWRegion, IWAdvRadioGroup, IWCompCheckbox, IWAdvMessageDialog, IWColor, IWTMSBase;

type
  TformAdvMessageDialog = class(TIWAppForm)

   FrameTopFrame1: TFrameTopFrame;
    FrameLeftFrame1: TFrameLeftFrame;
    TIWAdvMessageDialog1: TTIWAdvMessageDialog;
    IWButton1: TIWButton;
    cbDetailText: TIWCheckBox;
    cbCustomColors: TIWCheckBox;
    cbOverlay: TIWCheckBox;
    IWLabel1: TIWLabel;
    IWLabel2: TIWLabel;
    cbVerification: TIWCheckBox;
    cbIncludeRegion: TIWCheckBox;
    IWRegion1: TIWRegion;
    IWLabel3: TIWLabel;
    IWEdit2: TIWEdit;
    IWLabel4: TIWLabel;
    rgInput: TTIWAdvRadioGroup;
    rgPosition: TTIWAdvRadioGroup;
    cbYesNo: TIWCheckBox;
    IWEdit1: TIWEdit;
    cbCustomButton: TIWCheckBox;
    IWLabel5: TIWLabel;
    IWLabel6: TIWLabel;
    IWLabel7: TIWLabel;
    IWEdit3: TIWEdit;
    IWLabel8: TIWLabel;
    TIWDatePicker1: TTIWDatePicker;
    IWLabel9: TIWLabel;
    IWLabel10: TIWLabel;
    TIWAdvMessageDialog2: TTIWAdvMessageDialog;
    IWButton2: TIWButton;
    IWButton3: TIWButton;
    IWButton4: TIWButton;
    IWButton5: TIWButton;
    procedure IWButton1AsyncClick(Sender: TObject; EventParams: TStringList);
    procedure cbCustomColorsClick(Sender: TObject);
    procedure IWAppFormCreate(Sender: TObject);
    procedure cbOverlayClick(Sender: TObject);
    procedure cbDetailTextAsyncClick(Sender: TObject; EventParams: TStringList);
    procedure cbYesNoAsyncClick(Sender: TObject; EventParams: TStringList);
    procedure cbCustomButtonAsyncClick(Sender: TObject;
      EventParams: TStringList);
    procedure cbVerificationAsyncClick(Sender: TObject;
      EventParams: TStringList);
    procedure cbIncludeRegionAsyncClick(Sender: TObject;
      EventParams: TStringList);
    procedure rgInputAsyncClick(Sender: TObject; EventParams: TStringList);
    procedure rgPositionClick(Sender: TObject);
    procedure TIWAdvMessageDialog1AsyncButtonClick(Sender: TObject;
      EventParams: TStringList; ButtonIndex: Integer; InputString,
      InputPassword: string; InputCheck: Boolean; var Allow: Boolean);
    procedure IWEdit3AsyncExit(Sender: TObject; EventParams: TStringList);
    procedure IWEdit1AsyncExit(Sender: TObject; EventParams: TStringList);
    procedure IWButton2Click(Sender: TObject);
    procedure IWButton3Click(Sender: TObject);
    procedure IWButton4Click(Sender: TObject);
    procedure IWButton5Click(Sender: TObject);
  public
  end;

implementation

{$R *.dfm}

procedure TformAdvMessageDialog.cbCustomButtonAsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  TIWAdvMessageDialog1.CustomButtons.Clear;

  if cbCustomButton.Checked then
    TIWAdvMessageDialog1.CustomButtons.Add(IWEdit1.Text);

  TIWAdvMessageDialog1.Invalidate;
end;

procedure TformAdvMessageDialog.cbCustomColorsClick(Sender: TObject);
begin
  if cbCustomColors.Checked then
  begin
    TIWAdvMessageDialog1.CaptionBGColor := clWebGold;
    TIWAdvMessageDialog1.CaptionBGColorTo := clWebOrange;
    TIWAdvMessageDialog1.CaptionBorderColor := clWebRED;
    TIWAdvMessageDialog1.BGColor := clWebWHITESMOKE;
    TIWAdvMessageDialog1.BGColorTo := clWebSKYBLUE;
    TIWAdvMessageDialog1.ButtonBarBGColor := clWebOrange;
    TIWAdvMessageDialog1.ButtonBarBGColorTo := clWebGold;
    TIWAdvMessageDialog1.ButtonBarBorderColor := clWebBlack;
    TIWAdvMessageDialog1.CaptionFont.Color := clWebWhite;
    TIWAdvMessageDialog1.CloseButtonColor := clWebRed;
  end
  else
  begin
    TIWAdvMessageDialog1.CaptionBGColor := $00FCFCFC;
    TIWAdvMessageDialog1.CaptionBGColorTo := $00EDEDED;
    TIWAdvMessageDialog1.CaptionBorderColor := $007A7A7A;
    TIWAdvMessageDialog1.BGColor := clWebWhite;
    TIWAdvMessageDialog1.BGColorTo := clWebWhite;
    TIWAdvMessageDialog1.ButtonBarBGColor := $00F0F0F0;
    TIWAdvMessageDialog1.ButtonBarBGColorTo := $00F0F0F0;
    TIWAdvMessageDialog1.ButtonBarBorderColor := $00DFDFDF;
    TIWAdvMessageDialog1.CaptionFont.Color := clWebBlack;
    TIWAdvMessageDialog1.CloseButtonColor := clWebBlack;
  end;
end;

procedure TformAdvMessageDialog.cbDetailTextAsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  if cbDetailText.Checked then
    TIWAdvMessageDialog1.ExpandedText := 'Detail text'
  else
    TIWAdvMessageDialog1.ExpandedText := EmptyStr;
end;

procedure TformAdvMessageDialog.cbIncludeRegionAsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  if cbIncludeRegion.Checked then
    TIWAdvMessageDialog1.ContentRegion := IWRegion1
  else
    TIWAdvMessageDialog1.ContentRegion := nil;
end;

procedure TformAdvMessageDialog.cbOverlayClick(Sender: TObject);
begin
  if cbOverlay.Checked then
    TIWAdvMessageDialog1.OverlayOpacity := 3
  else
    TIWAdvMessageDialog1.OverlayOpacity := 0;
end;

procedure TformAdvMessageDialog.cbVerificationAsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  TIWAdvMessageDialog1.ShowVerificationCheckBox := cbVerification.Checked;
end;

procedure TformAdvMessageDialog.cbYesNoAsyncClick(Sender: TObject; EventParams: TStringList);
begin
  if cbYesNo.Checked then
    TIWAdvMessageDialog1.CommonButtons := [cbYes, cbNo]
  else
    TIWAdvMessageDialog1.CommonButtons := [cbOk];
end;

procedure TformAdvMessageDialog.IWAppFormCreate(Sender: TObject);
begin
  TIWAdvMessageDialog1.Caption := '<img src="/files/warning.gif"> TMS Software';
  TIWAdvMessageDialog1.VerificationText := 'Do not display this dialog again';

  TIWAdvMessageDialog2.Caption := 'IWAdvMessageDialog';
  TIWAdvMessageDialog2.Notes := '<br>IWAdvMessageDialog Custom Color Examples<br><br>';
  TIWAdvMessageDialog2.CommonButtons := [cbOK, cbCancel];
end;

procedure TformAdvMessageDialog.IWButton1AsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  TIWAdvMessageDialog1.Notes := 'Do you like the new <a href="http://www.tmssoftware.com/" target="_blank">TMS</a> <b>IWAdvMessageDialog</b> control for <a href="http://www.atozed.com/" target="_blank">IntraWeb</a>?<br>';
  TIWAdvMessageDialog1.PositionControl := IWButton1;
  TIWAdvMessageDialog1.ShowAsync;
end;

procedure TformAdvMessageDialog.IWButton2Click(Sender: TObject);
begin
  TIWAdvMessageDialog2.Font.Color := $12571A;
  TIWAdvMessageDialog2.Font.Size := 12;
  TIWAdvMessageDialog2.Font.FontName := 'Helvetica';
  TIWAdvMessageDialog2.BorderColor := $12571A;
  TIWAdvMessageDialog2.BorderWidth := 2;
  TIWAdvMessageDialog2.CaptionBGColor := $89E6CF;
  TIWAdvMessageDialog2.CaptionBGColorTo := $3FBE9E;
  TIWAdvMessageDialog2.CaptionBorderColor := $12571A;
  TIWAdvMessageDialog2.CaptionFont.Color := $12571A;
  TIWAdvMessageDialog2.CaptionFont.FontName := 'Helvetica';
  TIWAdvMessageDialog2.BGColor := $DCDCDC;
  TIWAdvMessageDialog2.BGColorTo := clWebWhiteSmoke;
  TIWAdvMessageDialog2.BGGradientDirection := gdHorizontal;
  TIWAdvMessageDialog2.ButtonBarBGColor := $89E6CF;
  TIWAdvMessageDialog2.ButtonBarBGColorTo := $89E6CF;
  TIWAdvMessageDialog2.ButtonBarBorderColor := $3FBE9E;
  TIWAdvMessageDialog2.CloseButtonColor := $12571A;
  TIWAdvMessageDialog2.RoundedBorderRadius := 8;
  TIWAdvMessageDialog2.ShowCloseButton := true;
  TIWAdvMessageDialog2.ShowShadow := true;
  TIWAdvMessageDialog2.OverlayOpacity := 2;

  TIWAdvMessageDialog2.Show;
end;

procedure TformAdvMessageDialog.IWButton3Click(Sender: TObject);
begin
  TIWAdvMessageDialog2.Font.Color := clWebBlack;
  TIWAdvMessageDialog2.Font.Size := 10;
  TIWAdvMessageDialog2.Font.FontName := 'Tahoma';
  TIWAdvMessageDialog2.BorderColor := $98593B;
  TIWAdvMessageDialog2.BorderWidth := 1;
  TIWAdvMessageDialog2.CaptionBGColor := $B4846D;
  TIWAdvMessageDialog2.CaptionBGColorTo := $B4846D;
  TIWAdvMessageDialog2.CaptionBorderColor := $B4846D;
  TIWAdvMessageDialog2.CaptionFont.Color := clWebWhite;
  TIWAdvMessageDialog2.CaptionFont.FontName := 'Tahoma';
  TIWAdvMessageDialog2.BGColor := clWebWhite;
  TIWAdvMessageDialog2.BGColorTo := clWebWhite;
  TIWAdvMessageDialog2.BGGradientDirection := gdVertical;
  TIWAdvMessageDialog2.ButtonBarBGColor := $F2F2F2;
  TIWAdvMessageDialog2.ButtonBarBGColorTo := $F2F2F2;
  TIWAdvMessageDialog2.ButtonBarBorderColor := $CCCCCC;
  TIWAdvMessageDialog2.CloseButtonColor := clWebWhite;
  TIWAdvMessageDialog2.RoundedBorderRadius := 0;
  TIWAdvMessageDialog2.ShowCloseButton := false;
  TIWAdvMessageDialog2.ShowShadow := true;
  TIWAdvMessageDialog2.OverlayOpacity := 0;

  TIWAdvMessageDialog2.Show;
end;

procedure TformAdvMessageDialog.IWButton4Click(Sender: TObject);
begin
  TIWAdvMessageDialog2.Font.Color := clWebBlack;
  TIWAdvMessageDialog2.Font.Size := 10;
  TIWAdvMessageDialog2.Font.FontName := 'Helvetica';
  TIWAdvMessageDialog2.BorderColor := clWebBlack;
  TIWAdvMessageDialog2.BorderWidth := 5;
  TIWAdvMessageDialog2.CaptionBGColor := clWebBlack;
  TIWAdvMessageDialog2.CaptionBGColorTo := clWebBlack;
  TIWAdvMessageDialog2.CaptionBorderColor := clWebBlack;
  TIWAdvMessageDialog2.CaptionFont.Color := clWebWhite;
  TIWAdvMessageDialog2.CaptionFont.FontName := 'Helvetica';
  TIWAdvMessageDialog2.BGColor := clWebWhite;
  TIWAdvMessageDialog2.BGColorTo := clWebWhite;
  TIWAdvMessageDialog2.BGGradientDirection := gdVertical;
  TIWAdvMessageDialog2.ButtonBarBGColor := clWebWhite;
  TIWAdvMessageDialog2.ButtonBarBGColorTo := clWebWhite;
  TIWAdvMessageDialog2.ButtonBarBorderColor := $F2F2F2;
  TIWAdvMessageDialog2.CloseButtonColor := clWebWhite;
  TIWAdvMessageDialog2.RoundedBorderRadius := 5;
  TIWAdvMessageDialog2.ShowCloseButton := true;
  TIWAdvMessageDialog2.ShowShadow := false;
  TIWAdvMessageDialog2.OverlayOpacity := 2;

  TIWAdvMessageDialog2.Show;
end;

procedure TformAdvMessageDialog.IWButton5Click(Sender: TObject);
begin
  TIWAdvMessageDialog2.Font.Color := $999999;
  TIWAdvMessageDialog2.Font.Size := 12;
  TIWAdvMessageDialog2.Font.FontName := 'Helvetica';
  TIWAdvMessageDialog2.BorderColor := $C49877;
  TIWAdvMessageDialog2.BorderWidth := 2;
  TIWAdvMessageDialog2.CaptionBGColor := $F4D5BC;
  TIWAdvMessageDialog2.CaptionBGColorTo := $C49877;
  TIWAdvMessageDialog2.CaptionBorderColor := $999999;
  TIWAdvMessageDialog2.CaptionFont.Color := clWebWhite;
  TIWAdvMessageDialog2.CaptionFont.FontName := 'Helvetica';
  TIWAdvMessageDialog2.BGColor := clWebWhite;
  TIWAdvMessageDialog2.BGColorTo := clWebWhite;//$FBEADD;
  TIWAdvMessageDialog2.BGGradientDirection := gdVertical;
  TIWAdvMessageDialog2.ButtonBarBGColor := clWebWhite;//$F1F1F1;
  TIWAdvMessageDialog2.ButtonBarBGColorTo := $FBEADD;//$F1F1F1;
  TIWAdvMessageDialog2.ButtonBarBorderColor := clWebWhite;//$F1F1F1;
  TIWAdvMessageDialog2.CloseButtonColor := clWebWhite;
  TIWAdvMessageDialog2.RoundedBorderRadius := 8;
  TIWAdvMessageDialog2.ShowCloseButton := false;
  TIWAdvMessageDialog2.ShowShadow := true;
  TIWAdvMessageDialog2.OverlayOpacity := 0;

  TIWAdvMessageDialog2.Show;
end;

procedure TformAdvMessageDialog.IWEdit1AsyncExit(Sender: TObject; EventParams: TStringList);
begin
  TIWAdvMessageDialog1.CustomButtons.Clear;

  if cbCustomButton.Checked then
    TIWAdvMessageDialog1.CustomButtons.Add(IWEdit1.Text);

  TIWAdvMessageDialog1.Invalidate;
end;

procedure TformAdvMessageDialog.IWEdit3AsyncExit(Sender: TObject; EventParams: TStringList);
begin
  if Length(IWEdit3.Text) < 5 then
  begin
    TIWAdvMessageDialog1.Notes := 'Please enter at least 5 characters.';
    TIWAdvMessageDialog1.PositionControl := IWEdit3;
    TIWAdvMessageDialog1.ShowAsync;
  end;
end;

procedure TformAdvMessageDialog.rgInputAsyncClick(Sender: TObject; EventParams: TStringList);
begin
  case rgInput.ItemIndex of
    0: TIWAdvMessageDialog1.InputType := itNone;
    1:
    begin
      TIWAdvMessageDialog1.InputType := itString;
      TIWAdvMessageDialog1.EmptyText := 'Your Comments';
    end;
    2: TIWAdvMessageDialog1.InputType := itInteger;
    3:
    begin
      TIWAdvMessageDialog1.InputType := itLogin;
      TIWAdvMessageDialog1.EmptyText := EmptyStr;
    end;
    4: TIWAdvMessageDialog1.InputType := itCheck;
  end;

  TIWAdvMessageDialog1.InputString := EmptyStr;
end;

procedure TformAdvMessageDialog.rgPositionClick(Sender: TObject);
begin
  case rgPosition.ItemIndex of
    0:
    begin
      TIWAdvMessageDialog1.Position := pCentered;
      TIWAdvMessageDialog1.PositionType := ptDefault;
    end;
    1:
    begin
      TIWAdvMessageDialog1.Position := pBottomRight;
      TIWAdvMessageDialog1.PositionType := ptDefault;
    end;
    2:
    begin
      TIWAdvMessageDialog1.PositionType := ptAtControl;
      TIWAdvMessageDialog1.PositionControl := IWButton1;
    end;
  end;
end;

procedure TformAdvMessageDialog.TIWAdvMessageDialog1AsyncButtonClick(Sender: TObject;
  EventParams: TStringList; ButtonIndex: Integer; InputString,
  InputPassword: string; InputCheck: Boolean; var Allow: Boolean);
begin
  if ButtonIndex = 0 then
    IWLabel1.Text := 'OK button clicked'
  else if ButtonIndex = 1 then
    IWLabel1.Text := 'Yes button clicked'
  else if ButtonIndex = 2 then
    IWLabel1.Text := 'No button clicked'
  else
    IWLabel1.Text := 'other button clicked';

  if (InputString <> EmptyStr) and (InputString <> TIWAdvMessageDialog1.EmptyText) then
    IWLabel1.Text := IWLabel1.Text + ': Input = ' + InputString;

  if TIWAdvMessageDialog1.VerificationCheckBoxChecked then
    IWLabel1.Text := IWLabel1.Text + ': Verification = checked';
end;

initialization

TformAdvMessageDialog.SetAsMainForm

end.
