Solved

Second form in taskbar problem

Posted on 2003-11-21
7
358 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
Technology Partners: 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

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!

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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