Solved

Forms and the Taswbar

Posted on 2003-11-24
8
242 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
[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
  • 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
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!

 
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Working with hours 3 89
CheckListBox usage 3 98
Twebbrowser in Fire monkey android scrolling to bottom 1 86
Problem working with dynamic array - help 2 49
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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