Solved

Align a form

Posted on 1997-07-13
9
457 Views
Last Modified: 2010-04-06
Hi!

I was wondering how I could align a form to the desktop, like the taskbar is align default to the bottom. I have tried form1.align:= altop; but that did not work :(

Thanks

Chr
0
Comment
Question by:chrb
[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
9 Comments
 
LVL 2

Expert Comment

by:icampbe1
ID: 1338786
Use the 'Screen' object to get the desktop client size.

Form1.Top := (Screen.Height - Height) DIV 2;
Form1.Left := (Screen.Width - Width) DIV 2;
etc etc

Cheers,
Ian C.
0
 

Author Comment

by:chrb
ID: 1338787
This centered the window, what I wanted was to align it to the top so no other windows go over it.

Chr
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1338788
If you want it at the top wouldn't you set Form1.Top := 0 ??
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!

 

Author Comment

by:chrb
ID: 1338789
I want to make a bar like the taskbar, if you don't set the option to hide automaticly none program will go over it. Excactly like if have a MDI form and put a component on it and align it, other MDI child will not go over it.

(Sorry my bad english)
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1338790
Now I understand what you are trying to do.  The screen or desktop is not exactly like a container (like a panel or form).  For example, if you run any pgm, it can be covered by another whether or not it is at the top of the desktop.  Let me see if there is a way to make the desktop look like it 'starts' lower (after the first pgm is running).
0
 
LVL 1

Expert Comment

by:millerw
ID: 1338791
It sounds like you want it to Stay on Top and not be covered by any other form.  If that is what you want check out the Object Inspector for the form.  There is a property called FormStyle.  It has the option of making the form fsStayOnTop.  No other program/form will go "over" the form, they will always go "under" the form.  

Then to align it to the top of the screen use the suggestion that icampbe1 gave and do your own calculations for the size of the form based on the Screen object (screen width and height are availible).  Use Top:=0 and Left:=0 to make it at the top and then assign the Width to the Screen Width and Height to whatever you want.  

I'm not sure how to INFORM Windows that the now availible screen area is less when not hiding and regular (minus a few pixels) when the your "taskbar" is in hide mode.  That can create problems later if a user starts a program and Windows places the title bar completely under your stay on top "taskbar."  There is probably an API call to tell windows that.  The problem is finding the right one :-)  I'll search for one if I have time.

Good Luck,
Scott
0
 

Author Comment

by:chrb
ID: 1338792
Increase to 120
0
 

Author Comment

by:chrb
ID: 1338793
I have found out that I must use the shappbarmessage, but I can't get it work :(
procedure TForm1.OnCreate(Sender: TObject);
var
 AppBar: tAppBarData;
 I: Integer;
begin
 AppBar.cbSize:= SizeOf( tAppBarData);
 AppBar.hWnd:= Handle;
 AppBar.uEdge:= ABE_TOP;
 I:= SHAppBarMessage( ABM_NEW, AppBar);
end;

Please help ! Thanks !

Chr
0
 
LVL 1

Accepted Solution

by:
ygolan earned 120 total points
ID: 1338794
This is actually quite complicated. I suggest that you search for a component called appbar12.zip in the Delphi Super Pages (or other Delphi sites), it's a freeware that implements this feature.

Yaniv
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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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