Forum > LCL

Dialogs - QuestionDlg ...

(1/3) > >>

I'm just an amateur programmer who tries to understand Pascal and program everything through self-study and 'Google (Forums)'. My knowledge is really limited.
It would be a good idea to be able to choose a bitmap for the buttons in a 'questiondlg' or other dialogue messages. This instead of the normal text 'yes'-'no' - or - as a supplementary option.
Perhaps this can become an additional option in the current component.
Thanks with greetings from Belgium.

Hello and Welcome!

You can build your own dialogs, if you want or need to. And is possible to make them available at the component pallet too.

Check it out:

If you start with the CreateMessageDialog function in dialogs unit, then you have access to the underlying form.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button2Click(Sender: TObject);var  F: TForm;  i: Integer;  C: TComponent;  B: TBitBtn;  Res: TModalResult;begin  F := CreateMessageDialog('Dare to take a choice?', 'Do you want to format your harddrive?', mtConfirmation, [mbYes, mbNo, mbAbort, mbRetry, mbCancel, mbOK]);  for i := 0 to F.ComponentCount-1 do  begin    C := F.Components[i];    if (C is TBitBtn) then    begin      B := TBitBtn(C);      case B.Kind of        bkYes: B.Caption := 'No';        bkNo: B.Caption := 'Yes';        bkAbort: B.Caption := 'Ok';        bkRetry: B.Caption := 'Cancel';        bkCancel: B.Caption := 'Retry';        bkOk: Caption := 'Abort';      end;    end;  end;  Res := F.ShowModal;  F.Free;end;
In this simple code I change the buttons captions, just to confuse them.
You can do anything you want with the buttons now you have access to them.

I use a similar approach to have a checkbox with "Don't show this dialog anymore" on the dialog.
Note: You cannot access the components anymore after you freed the form (F in this case).


Nice to know about it, Bart! Thank you!

Thank you for your information.
I'll try it.


[0] Message Index

[#] Next page

Go to full version