Ian Branch 127 Posted January 18, 2021 Hi Team, D10.4.1, 32bit App, Windows 10. I think I have chased this up once before but I can neither find it or recall where. Please see the attached short video. At the start the Main Form is open. Click the Audio button and the Audio form is opened, then the Print Listing option selected. Note the Main Form appears at the same time but under the Print dialog. When the Print dialog is closed they both disappear. Obviously I don't want the Main Form to appear when the dialog is called, even though it doesn't hamper the usage. As far as I can tell, everything is being called correctly. I am open firstly to understanding why the Main Form is appearing, and secondly, how to prevent it. Regards & TIA,. Ian MMLIssue.mp4 Share this post Link to post
balabuev 102 Posted January 18, 2021 You do something special in your application's code. It's obvious, because the issue cannot be reproduced with simple test project. Share this post Link to post
Ian Branch 127 Posted January 18, 2021 And that's a reasonable assumption except I can't find anything to account for it. I have eliminated everything in the MainForm Create & Show events. The Audio form is called with a simple.. AudioForm := TAudioForm.Create(Self); AudioForm.Show; All the AudioForm does on Creation is open tables. There is nothing in the Show event. I thought it might have been something in the Project file but I can't see anything there that would contribute/cause this. Ian Share this post Link to post
balabuev 102 Posted January 18, 2021 Can you also provide the code, which shows the dialog? Share this post Link to post
Lars Fosdal 1792 Posted January 18, 2021 Which form is the parent/owner of the print dialog? Share this post Link to post
Lajos Juhász 293 Posted January 18, 2021 I was able to reproduce this behavior when Application.MainFormOnTaskbar := false and the third form is modal with PopupParent is the mainform. Share this post Link to post
David Heffernan 2345 Posted January 18, 2021 A minimal reproduction would make it simple to resolve the issue. Share this post Link to post
Ian Branch 127 Posted January 18, 2021 All, Thank you for your input. Appreciated. Something Lajos said.. 58 minutes ago, Lajos Juhász said: PopupParent is the mainform. Triggered something in my head. Having another look at the code in the Sub Form I found this.. ... .... private { Private declarations } public { Public declarations } protected procedure CreateParams(var Params: TCreateParams); override; end; var And this.. procedure TAudioForm.CreateParams(var Params: TCreateParams); begin inherited; Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW; Params.WndParent := 0; end; Now, I have no recollection of what that code was put in for, oh so long ago, but if I comment it out all is good. No more MainForm appearing. Can someone enlighten me as to why I would have put that there?? I'm sure I put it there for a reason. ;-) Ian Share this post Link to post
balabuev 102 Posted January 18, 2021 (edited) Quote WS_EX_APPWINDOW Forces a top-level window onto the taskbar when the window is visible. Edited January 18, 2021 by balabuev Share this post Link to post
David Heffernan 2345 Posted January 18, 2021 18 minutes ago, Ian Branch said: WS_EX_APPWINDOW A web search for this flag would tell you what you need to know. Always worth remembering that web search exists. I find it terribly useful. Share this post Link to post
Ian Branch 127 Posted January 18, 2021 Hi Guys, Thanks for the pointers. I found the answer here.. http://www.delphigroups.info/2/e6/483281.html I recall now the User was complaining that dialogs were being hidden by the form. That was in an earlier Delphi. I shall have to experiment a little to see if the issue still persists now I have commented out that piece of code. Thanks again. Ian Share this post Link to post
Remy Lebeau 1396 Posted January 19, 2021 (edited) On 1/18/2021 at 12:35 AM, Lajos Juhász said: the third form is modal with PopupParent is the mainform. That is wrong. The PopupParent should be the AudioForm instead, since it is the one invoking the print dialog. On 1/18/2021 at 1:38 AM, Ian Branch said: Now, I have no recollection of what that code was put in for, oh so long ago, but if I comment it out all is good. No more MainForm appearing. Can someone enlighten me as to why I would have put that there?? I'm sure I put it there for a reason. 😉 There is only 1 good reason to ever do that - if you want the AudioForm to be a top-level window (acting as a sibling of the MainForm, so either Form could appear on top of the other at any time) with its own button on the Taskbar. Otherwise, without that code, the AudioForm would by default be owned by the TApplication window (when Application.ShowMainFormOnTaskbar=false) or the MainForm window (when Application.ShowMainFormOnTaskbar=true), and thus would not have a Taskbar button, and would always appear on top of its owner, never underneath it. Edited January 19, 2021 by Remy Lebeau Share this post Link to post
Attila Kovacs 629 Posted January 19, 2021 (edited) On 1/18/2021 at 11:03 AM, Ian Branch said: That was in an earlier Delphi. No, it's still present if a form takes more than 5 seconds to display. But that doesn't mean you have to make the main form as popup parent always (I guess). I would set it to the caller form. Edited January 19, 2021 by Attila Kovacs Share this post Link to post
Ian Branch 127 Posted January 19, 2021 2 hours ago, Attila Kovacs said: I would set it to the caller form. Shouldn't it be that by default? Share this post Link to post
balabuev 102 Posted January 20, 2021 (edited) 8 hours ago, Ian Branch said: Shouldn't it be that by default? This can be achieved by setting form's PopupMode to pmAuto (can't say, why it's not default): if FCreatingMainForm then WndParent := 0 else WndParent := Application.ActiveFormHandle; // <------ ... Edited January 20, 2021 by balabuev Share this post Link to post