Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Second form in taskbar problem

Posted on 2003-11-21
7
Medium Priority
?
363 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 375 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 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