Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Forms and the Taswbar

Posted on 2003-11-24
8
Medium Priority
?
246 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
Independent Software Vendors: 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 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

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

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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

670 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