Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Forms and the Taswbar

Posted on 2003-11-24
8
Medium Priority
?
247 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
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.

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

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

886 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