TeamB website had a solution posted by Deepak Shenoy back in 2006, but the website is down. So, here is a copy of that page:
Yes. Going through the Delphi source code in Forms.pas, in TForm.ShowModal() a call to "DisableThreadWindows" is made to ensure that all non modal forms are inactive, and when the modal form is closed "EnableThreadWindows" is called. What these do is simply disable all other windows and then re-enable them.
What you can do is:
- Handle the WM_ENABLE message that is sent to your form to set the enabled state.
- Use "PostMessage" to post a custom message (say WM_REENABLE) back to your form.
- Handle the WM_REENABLE custom message and in the handler, Enable your window.
So in your Delphi form create a form like so:
type
TForm2 = class(TForm)
…
procedure WMEnable(var Message: TWMEnable); message WM_ENABLE;
…
procedure TForm2.WMEnable(var Message: TWMEnable);
begin
if not Message.Enabled then
PostMessage(Self.Handle, WM_REENABLE, 1, 0);
end;
where WM_REENABLE is defined earlier as:
const
WM_REENABLE = WM_USER + $100;
Then add a WM_REENABLE handler like this:
type
TForm2 = class( TForm )
…
procedure WMReenable(var Message: TMessage); message WM_REENABLE;
…
procedure TForm2.WMReenable(var Message: TMessage);
begin
EnableWindow(Self.Handle, True);
end;
Now your form will be active even if a modal window is shown.
Note: I have tried the following and they do not work:
- Calling EnableWindow() in the WM_ENABLE handler.
- Posting a WM_ENABLE message in the WM_ENABLE handler.
- Trying to change Window styles of my window to Stay on Top.
Note: Do not call "SendMessage" instead of PostMessage, it will not work consistently.
But if you ask me, I am 101% on @mghie's side: Don't program against the operating system/platform. Don't do something that is so totally different from what the user (and the OS) expects.
Maybe that modal window is not that "modal" as you think. Check why you need to "lock" that window in modal state and probalby that thing, is something you need to change in your architecture.
In hte worst case, maybe you could reparent the log into the modal window.