Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Main form and mult copies of same child form (diff data) - modal win prob


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Aug 31, 2017 12:19 PM Last Post By: Keith Marbach Threads: [ Previous | Next ]
Keith Marbach

Posts: 69
Registered: 8/21/01
Main form and mult copies of same child form (diff data) - modal win prob  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2017 8:46 AM
I mimic Outlook in that I have a main form with rows of records. User can double click on a row to open info in a separate non-modal form. User can open multiple of these non-modal forms.

The non-modal child form has this code:

procedure TfrmChild.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow;
end;

This works well except for one issue I'm not sure how to fix.

The child form has a TcxImage (Dev Express) control. User can right click that and select "Load" from menu to open a modal dialog to select an image to load into the Tcximage. When the Load dialog closes, the main form is displayed rather than the child form. The z-order gets whacked. I've dealt with this issue (child form opens modal window, need child form to be on top when modal window closes) before when I control the code of the modal window, but in this case I'm using a DevExpress control that is opening that modal window, so I don't have control over the showModal or the properties of the modal window. Any ideas how to fix, which would look like this:

Main form opens child window. Child window opens modal dialog (Dev Express). Modal window closes. Child window on top.

And not this, which is what currently happens:

Main form opens child window. Child window opens modal dialog (Dev Express). Modal window closes. MAIN window on top.

Thanks for any suggestions.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Main form and mult copies of same child form (diff data) - modal win prob  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2017 10:10 AM   in response to: Keith Marbach in response to: Keith Marbach
Keith Marbach wrote:

When the Load dialog closes, the main form is displayed rather than
the child form. The z-order gets whacked.

That implies that the main form, not the child form, is being set as
the owner window for the modal window. Or worse, that the dialog code
is not managing owner activation correctly when the dialog is closed.

Ownership is very important when modality is concerned. Raymond Chen
has a whole blog series on this topic:

https://blogs.msdn.microsoft.com/oldnewthing/tag/modality

https://blogs.msdn.microsoft.com/oldnewthing/20040227-00/?p=40463

in this case I'm using a DevExpress control that is opening that modal
window, so I don't have control over the showModal or the properties
of the modal window.

Then you might be SOL. Talk to DevExpress about this issue.

Assuming a standard modal TForm, ShowModal() uses the currently focused
TForm as the owner window. If that TForm window has the
WS_EX_TOOLWINDOW style, ShowModal() hunts for a parent window that does
not have the WS_EX_TOOLWINDOW style. If no suitable window can be
found, the MainForm is used, unless it also has the WS_EX_TOOLWINDOW
style, in which case the TApplication window is used.

--
Remy Lebeau (TeamB)
Keith Marbach

Posts: 69
Registered: 8/21/01
Re: Main form and mult copies of same child form (diff data) - modal win prob  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2017 12:19 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you! I'll talk to DevExpress to see what can be done.

Assuming a standard modal TForm, ShowModal() uses the currently focused
TForm as the owner window. If that TForm window has the
WS_EX_TOOLWINDOW style, ShowModal() hunts for a parent window that does
not have the WS_EX_TOOLWINDOW style. If no suitable window can be
found, the MainForm is used, unless it also has the WS_EX_TOOLWINDOW
style, in which case the TApplication window is used.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02