Solved

Second form in taskbar problem

Posted on 2003-11-21
7
354 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now