Solved

Forms and the Taswbar

Posted on 2003-11-24
8
240 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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