Non-MainForm to Task Bar

Hi there,

how do i bring a dynamically created Form of my D4-Program to the TaskBar,  where the Program's Main Form is while running, like Microsoft OutLook Expres does, when you create a new eMail-Message ?
LVL 2
omsecAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RadlerCommented:
Hi omsec,

Change the style of the window and your visibility.
var
St : DWORD;
begin

    ShowWindow(Application.Handle, SW_show);
    St:=GetWindowLong(Application.Handle, GWL_EXSTYLE);
    SetWindowLong(Application.Handle, GWL_EXSTYLE,
      St or  WS_EX_APPWINDOW);

end;


T++, Radler.
0
intheCommented:
this is what i'd do on a normal form to make it independant of the mainform so i caould also minimize it:

private
 procedure CreateParams(var Params : TCreateParams); override;
public
    { Public declarations }
  end;

procedure TForm2.CreateParams(var Params : TCreateParams);
begin
  inherited CreateParams(Params);
Params.WndParent := GetDesktopWindow;
end;

might be able to work it also on a created form.just sets the paretn of the form to the desktop .
0
omsecAuthor Commented:
but how is Form2 dispalid in that case ?

my current code is

Form2 := TForm2.Create(self);
try
  // assign some Form2-Vars
  Form2.ShowModal;
finally
  Form2.Free;
end;

still something like this ?
0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

intheCommented:
works ok like this by setting the parentwindow as desktop:

procedure TForm1.Button1Click(Sender: TObject);
var
newform : tform;
begin
newform := tform.Create(self);
newform.ParentWindow := getdesktopwindow;
newform.Left := 40;
newform.Top := 100;
newform.Width := 200;
newform.Height := 200;
newform.Color := clblue;
newform.Caption := 'New Form';
newform.Icon := application.Icon;
newform.ShowModal;
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omsecAuthor Commented:
inthe:

your code works perfectly. before i grade it, just a last thing...

how would i check if that window is created ? Usign the Assign-Function ?
if its closed (not created) ill (re-)create it, otherwiese just assign new data to it, if required.
0
intheCommented:
hi omsec ,
make it global the var then use if assigned(newform)...
like below:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  newform : tform;
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
if assigned(newform) then
showmessage('form already created')
else begin
newform := tform.Create(self);
newform.ParentWindow := getdesktopwindow;
newform.Left := 40;
newform.Top := 100;
newform.Width := 200;
newform.Height := 200;
newform.Color := clblue;
newform.Caption := 'New Form';
newform.Icon := application.Icon;
newform.Show;
end;
end;
end.


Regards Barry
0
ShadowHawk071998Commented:
Hello guys.
I tried your answer. IT worked good, but I had a problem that the displayed new window does not seem to get focus, it behaves weirdly (like it's always out of focus, it is never 'active'), and buttons don't work.

Only if I set it to border style 'Dialog' it works okay - but this doesn't really help me, because I want it to have minimize control.

Any ideas?

M.
0
ShadowHawk071998Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.