Solved

Align a form

Posted on 1997-07-13
9
455 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
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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