?
Solved

Lots of topmost forms in one application

Posted on 2005-03-15
7
Medium Priority
?
435 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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!

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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