Forum > LCL
[FIXED] Dialog ShowModal and an icon within caption bar?
d7_2_laz:
I sometimes already had noticed, but yet never really paid attention to:
Windows 10 64bit, Lazarus 3.2
A subform with BorderStyle bsDialog, opened with ShowModal, normally doesn’t have an icon within the caption bar.
But sometimes it has … and I would like to keep this / to have it as a useable feature, to be used by intention, rather than to be seen as a bug ….
But when does the icon do appear? If eg. a TDateTimePicker within the dialog is opened.
Looks like as if BorderIcons := [biSystemMenu], if set, would have come into effect just now, but not at dialog’s start.
Edit:
Maybe it’s better to express it vice versa:
if BorderIcons := [biSystemMenu] can be defined, then SystemMenu / Icon should be visible from the beginning. – Or is it by design that it does not?
ASerge:
You can see this bug and its causes without TDateTimePicker:
--- 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.Button1Click(Sender: TObject);var LForm: TForm; LTimer: TTimer;begin LForm := TForm.Create(Self); LTimer := TTimer.Create(LForm); LTimer.Interval := 2 * MSecsPerSec; LTimer.OnTimer := @Timer1Timer; LForm.Parent := Self; LForm.Show;end; procedure TForm1.FormCreate(Sender: TObject);begin BorderStyle := bsDialog;end; procedure TForm1.Timer1Timer(Sender: TObject);begin ((Sender as TComponent).Owner as TForm).BorderStyle := bsDialog;end;
d7_2_laz:
Thanks ASerge; tried -– true. But, do one see also the causes here? Hm.
It did remind me somehow at my first rough thought when noticeing the calender thing:
looks like the system menu / icon becomes visible just at the moment when the dialog itself is no longer topmost (is slipping to background). Rather than to be specific related to a DateTimePicker of course.
Btw, reading around in web (Lazarus and Delphi) I was pretty unsure if at the end BorderStyle bsDialog and BorderIcons biSystemMenu are really foreseen to legitimately coexist. It stays a bit vague for me if they too belong to those which are “mutually exclusive”.
https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Forms.TCustomForm.BorderIcons
See also the old problem report about “bsDialog Form shows Icon” as being a bug (but, why a bug??)
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/19321
I think it would be useful to clarify first whether “modal dialog” and “system menu” is a valid combination or not. Probably there might be different opinions.
ASerge:
--- Quote from: d7_2_laz on March 27, 2024, 08:25:18 pm ---Thanks ASerge; tried -– true. But, do one see also the causes here? Hm.
--- End quote ---
TDateTimePicker uses a nested form for the calendar.
The problem is that in Lazarus changes to the border style of a nested form are reflected on the parent form.
There is no such thing in Delphi.
d7_2_laz:
ASerge ok, understood …
But let’s put this buggy side-effect for a moment besides (removing here the datetimepicker):
I’d still unsure (probably I’m the only one?) what would be the correct behaviour:
Does and should by principle a modal dialog exclude the display of an icon (resp. system menu)?
Or should it be possible to display the icon if wanted and configured (ie. by setting BorderIcons biSystemMenu)?
For the cases the latter might be wanted (may happen) I found this little workaround:
--- 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";}};} --- TForm2 = class(TForm) // Form2 is the modal dialog here ….. protected procedure CreateWnd; override; ….. procedure TForm2.CreateWnd;begin inherited; // --- Assure icon display picked up from application icon: //SendMessage(Handle, WM_SETICON, ICON_BIG, Windows.LoadIcon(MainInstance, 'MAINICON')); // --- Assure icon display picked up from the form's icon handle: Windows.SendMessage(Handle, WM_SETICON, ICON_BIG, Self.BigIconHandle); end;
Navigation
[0] Message Index
[#] Next page