Solved

Second form in taskbar problem

Posted on 2003-11-21
7
356 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
QRReport  TQrmemo vertical stretching 1 46
can't find the executable in Simulator 1 90
update joined tables 2 46
Installshield for Embarcadero EX 10.1 Berlin 4 40
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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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