Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Lots of topmost forms in one application

Posted on 2005-03-15
7
Medium Priority
?
446 Views
Last Modified: 2010-04-05
hi iv had a bug 4 a while now that i cant seam to squish

i want more than one form per application to stay topmost but i can only get 1 form at any one time topmost any ideas...

each child form calls when its deactivated

SetWindowPos(Application.Handle,HWND_TOPMOST,0,0,0,0,
  SWP_NOACTIVATE or SWP_HIDEWINDOW or SWP_NOSIZE or SWP_NOMOVE);

the only problem is only the first form that was created retains topmost
must be something very simple! lol
regards mark,
0
Comment
Question by:mgazza
  • 3
  • 3
7 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13548149
you can only have 1 form "in front" per say, so that windows knows where to send the events such as keystrokes etc.
If you need to change which window is in front you can do a "BringToFront"
0
 
LVL 1

Author Comment

by:mgazza
ID: 13548897
the key strokes dont go though the main form i must be able to set more than one infront maybe if i use a mdi form and set everything inside that..... any sujections would be gr8!
regards
mark.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 13549184
What do you mean with "each child form calls when its deactivated"?
Form is deactivated when another form in same application receives focus. If the whole app is deactivated, it doesn't mean that form is deactivated. From Delphi help:
"Use OnDeactivate to perform special processing when the form transitions from being the active form to another form in the same application becoming the active form. If activation goes to another application, this event is not triggered. To determine if another application has become active, Use the TApplication object’s OnDeactivate event."
Maybe you should process application's onDeactivate event, not forms'?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 11

Accepted Solution

by:
ZhaawZ earned 300 total points
ID: 13549280
Project --> View Source:

program Project1;

uses
  Forms, Windows,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2},
  Unit3 in 'Unit3.pas' {Form3};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  SetWindowPos(Application.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
  SetWindowPos(Form1.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
  SetWindowPos(Form2.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
  SetWindowPos(Form3.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
  Form2.Show;
  Form3.Show;
  Application.Run;
end.

------------------------------------------

Unit1:

unit Unit1;

interface

uses
  Windows, Classes, Forms;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure AppDeactivate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

uses Unit2, Unit3;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnDeactivate := AppDeactivate;
end;

procedure TForm1.AppDeactivate(Sender: TObject);
begin
SetWindowPos(Application.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
SetWindowPos(Form1.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
SetWindowPos(Form2.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
SetWindowPos(Form3.Handle, hwnd_topmost, 0, 0, 0, 0, swp_noactivate or swp_nomove or swp_nosize);
end;

end.
0
 
LVL 1

Author Comment

by:mgazza
ID: 13549410
ty that works i ant i noob just couldnt figure out why i changed ondeactivate to onidle cause its just better lol

best regards mark
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 13549430
Didn't understand your english...
0
 
LVL 1

Author Comment

by:mgazza
ID: 13549461
oh sorry!
i said, thankyou that works im not a newby, i just never done this before i changed the on activate to onidle but this is not needed since you only need to call this function once :)

best regards mark
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

569 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