Solved

Align a form

Posted on 1997-07-13
9
459 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month4 days, 9 hours left to enroll

635 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