Solved

Align a form

Posted on 1997-07-13
9
451 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now