Solved

Forms and the Taswbar

Posted on 2003-11-24
8
237 Views
Last Modified: 2010-04-05
Hi

Delphi 7 Question

How do you show just the active form in the taskbar?

I have the Application in the Taskbar and the minimised form sitting minimised on the desktop next to the taskbar (not in the taskbar as I would with VB) - this seems crazy.

Voodooman
0
Comment
Question by:Voodooman
  • 5
  • 3
8 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 9811813
Hi,

Two ways:
1. Showing Form2 from Form1 this way (no additional code in Form2):
procedure TForm1.Button1Click(Sender: TObject);
begin
  SetWindowLong(Form2.Handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
  Form2.Show;
end;

2. Changing Form2 code only (calling it as usual):

unit Unit2;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
 TForm2 = class(TForm)
 private
   { Private declarations }
 public
   { Public declarations }
   // or private or protected
   procedure CreateParams(var Params:TCreateParams); override;
 end;

var
 Form2: TForm2;

implementation

{$R *.DFM}

procedure TForm2.CreateParams(var Params:TCreateParams);
begin
 inherited CreateParams(Params);
 Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
 // and if you want the following line makes the form not to bring other forms in the app to foreground
 // Params.WndParent := GetDesktopWindow;
end;

end.

Regards, Geo
0
 
LVL 5

Author Comment

by:Voodooman
ID: 9811908
Hi

Thanks for the reply.  I have tried various versions of the above - and can achieve something of a result.

I get various errors which seem to be related to the fact that I create all the forms at runtime.

The problems occurr when I try to close any forms that appear in the taskbar with the above methods.

Voodooman
0
 
LVL 17

Expert Comment

by:geobul
ID: 9811976
Hi,

>I get various errors which seem to be related to the fact that I create all the forms at runtime.

This doesn't matter. I removed that part from Ex.1 above. How are you creating your forms? Post your way and I'll test it.

Regards, Geo
0
 
LVL 5

Author Comment

by:Voodooman
ID: 9812068
Hi

Getting a little further with this using the

 procedure CreateParams(var Params:TCreateParams); override;


The problem is that when I show a form modal (popup) the whole thing falls to pieces.

I get two icons in the taskbar and if I click on the non modal form icon the modal form goes to the back - how bizarre is that!

Voodooman
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 5

Author Comment

by:Voodooman
ID: 9812080
Hi

sorry our message crossed

I create the forms with this


Application.CreateForm(TF_ProjectMain,F_ProjectMain);


Voodooman
0
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 9812223
Use
F_ProjectMain := TF_ProjectMain.Create(Application);
instead.

About ShowModal: don't use
Params.WndParent := GetDesktopWindow;
for that form.

What is your goal actually? How do you expect such a form to behave itself in both normal and modal state? If you wanted that second form to look like a separate app you shouldn't show it in modal state then. Isn't that right?

Regards, Geo
0
 
LVL 5

Author Comment

by:Voodooman
ID: 9812271
Hi Geo

I do have to use popups evrywhere.

My project is a database project for property developers.  

Users need to

e.g. Select a Project to work on.

Select from a list etc to add 'Development Areas'

Create Areas.

They would look silly as full screens

This is just normal 'Everyday' in VB.

Voodooman
0
 
LVL 5

Author Comment

by:Voodooman
ID: 9823354
Hi Geo

Thanks for your help.  I cant believe that you have to go to all this trouble to get an App to behave in the way that users expect!

I am a professional VB Programmer (11 years) and database specialist.  I have tried several times to sell my own software with some success.  One of the problems is that VB programs are just too big to download - hence I have now come back to Delphi.

All my stuff is database (adding editing etc) hence I need popups.

I used this code which works great - but why should I have to add code to every form 0/10 to Borland for this!

//Put this in the Create Application of the first form
//stops the application getting in the toolbar
//****************************************************
SetWindowLong( application.handle, GWL_EXSTYLE,
     GetWindowLong( application.handle, GWL_EXSTYLE )
     or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW );
     
     
//********************************************************
//This for normal forms - force the window into the taskbar
//*********************************************************
procedure TForm1.CreateParams

   (var Params: TCreateParams);

  begin
    inherited CreateParams(Params);
    with Params do begin
      ExStyle := ExStyle or WS_EX_APPWINDOW;
      WndParent := GetDesktopwindow;
    end;
  end;


//********************************************************
//This for modal forms - keeps the form on top
//when the taskbar icon is clicked
//*********************************************************
procedure CreateParams(var Params:TCreateParams); override;

procedure TF_Projects.CreateParams

   (var Params: TCreateParams);

  begin
    inherited CreateParams(Params);
    with Params do begin
      WndParent := F_Main.Handle;
    end;
  end;

I am happy to award you the points.

Voodooman
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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