Solved

Second form in taskbar problem

Posted on 2003-11-21
7
359 Views
Last Modified: 2010-04-05
Hi,

I'm showing a second form in the taskbar to look like it is a second application. I'm using the following code to achieve this:

procedure TfrmEditor.CreateParams(var Params: TCreateParams);
begin
  inherited;

  with Params do begin
    ExStyle := (ExStyle or WS_EX_APPWINDOW);
    WndParent := GetDesktopWindow;
  end;
end;

Problem now is that whenever I show another form Modal ontop of this form (for example a MessageBox), the window disappears to show the main form and reapears again only when I close the modalshowed form.

Anyone knows how to solve this? I already tried to not set the HwndParent but that will mess with minimize and Alt-Tab.
0
Comment
Question by:Troplosti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 9796242
Hi,

Add this to your main form (no other changes are necessary):

type
 TForm1 = class(TForm)
 ...
 private
   procedure WMEnable(var message: TWMEnable); message WM_ENABLE;
 ...
 end;

implementation
...
procedure TForm1.WMEnable(var message: TWMEnable);
begin
 if not message.Enabled then
   EnableWindow(handle, True);
end;

Regards, Geo
0
 

Author Comment

by:Troplosti
ID: 9797003
This does not seem to help at all. Nothing really changes. I'll explain my problem in somewhat more detail. I have the mainapplication which is a MDI application. Let the main form (MDIParent) be frmMain and let the MDIChidren be instances of frmClient. Than somewhere in frmClient I create a new instance of frmEditor which has the above CreateParams procedure.

Everything works okay at this stage, that is, it seems that windows handles both forms as seperate applications (in taskbar and in Alt-Tab window). Also the frmEditor form does not minimize when I minimize the main form. The only problem is that when I show a MessageBox or any other modal form from within a frmEditor instance, the frmEditor Form seems to disappear, the frmMain (MDIParent) shows and ontop of that I see the MessageBox. When I close the messagebox the frmEditor appears again and everything is back to normal.

It just occured to me that when I minimize frmMain and leave frmEditor showed none of this happens and it works just the way I want. When frmMain is showed it's messed up.
0
 
LVL 17

Expert Comment

by:geobul
ID: 9797119
Well, you didn't say it's a MDI app. My solution works well for normal apps.
I also understood that your main form disapears. My mistake.
Try changing frmEditor form FormStyle to fsNormal. The same applies for all other forms that frmEditor shows in modal state. Also create frmEditor form this way:

frmEditor := TfrmEditor.Create(nil); // without a owner

Regards, Geo
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Troplosti
ID: 9797179
Hmm, my forms already were fsNormal. I found out now that if I use this in the CreateParams of the windows showed on top of frmEditor:

  with Params do begin
    WndParent := TForm(Owner).Handle;
  end;

It works like I wanted, but still MessageBoxes make frmEditor disappear.
0
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 9797339
Use windows.MessageBox(frmEditor.Handle, etc) instead of Application.MessageBox. The reason is that Application.MessageBox uses windows.MessageBox giving Application.Handle as first parameter and therefore the MessageBox sits on top of the Application (your main form).

Regards, Geo
0
 

Author Comment

by:Troplosti
ID: 9797379
Thanks, works like a charm :)
0
 
LVL 17

Expert Comment

by:geobul
ID: 9797447
You are welcome :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 76
how to center only a line in richedit? 4 78
enhance the following code 3 53
Remove all child-forms from a parent-panel 16 13
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question