Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Buttons of ModalWindow - enabled:= true / false
#1
Hello.
How do I control the accessibility of buttons in a modal window?
In delphi, I would do something like this:

  Button1.Enabled: = ChechkBox1.Checked and (ComboBox.ItemIndex <> -1);

But in IWModalWindow Buttons is a TStringList. How do I access the properties of buttons? I've tried  like this :
var
  Button: TIWButton;
begin
  Button: = TIWButton (ModalWindow.Buttons.Objects[0]);
  Button.Enabled: = false  // Button = nil
end;
But it doesn't work.

Or not to use ModalWindow.Buttons for such cases? Just use the standard buttons taken from the palette and added inside the ModalWindow panel?
Reply
#2
Hi, see this demo.
Code:
  with IWModalWindow1 do begin
    Reset;
    Buttons.CommaText := '&Yes,&No,&Cancel,"I give &up|NoClose"';
    ...
    Show;
  end;
Code:
procedure TIWForm60.WindowDoOnAsyncClick(Sender: TObject; EventParams: TStringList);
var
  BtnCaption: string;
begin
  if IWModalWindow1.ButtonIndex >= 0 then begin
    BtnCaption := IWModalWindow1.ButtonCaption[IWModalWindow1.ButtonIndex]; // First ButtonIndex is 1, not 0
    WebApplication.ShowMessage('You clicked on button: ' + BtnCaption);
  end;
end;
Reply
#3
(03-11-2021, 10:52 AM)Jose Nilton Pace Wrote: Hi, see this demo.
Code:
  with IWModalWindow1 do begin
    Reset;
    Buttons.CommaText := '&Yes,&No,&Cancel,"I give &up|NoClose"';
    ...
    Show;
  end;
Code:
procedure TIWForm60.WindowDoOnAsyncClick(Sender: TObject; EventParams: TStringList);
var
  BtnCaption: string;
begin
  if IWModalWindow1.ButtonIndex >= 0 then begin
    BtnCaption := IWModalWindow1.ButtonCaption[IWModalWindow1.ButtonIndex]; // First ButtonIndex is 1, not 0
    WebApplication.ShowMessage('You clicked on button: ' + BtnCaption);
  end;
end;

Thank you Jose,
I've seen this example earlier.
This example does not answer my question.
Using the NoClose parameter, you can set the button behavior before the modal window appears.
I want to control the behavior of the button while the modal is already open.
Reply
#4
Hello,
in this example Buttons.CommaText := '&Yes,&No,&Cancel,"I give &up|NoClose"';

The selected button is for default yes, always the first button, is there any possibly to set another button as default?

Thank you very much.

kind regards,

Blanca
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)