Basically I have a label which I do the following with on start up of my application:

with Label1 do
   Caption := 'Computer Locked';
   Align := alClient;
   Alignment := taCenter;
   Top := 400;

Now the problem I have is the alClient and taCenter work perfectly making the label in the middle of the screen but the problem is it display the label right at the top of the screen in the middle. I want to display the label in the middle of the screen and then down from the top by 400 which is why I used the code "Top := 400" but it makes no difference and instead the label displays as if "Top := 0" which I have no idea how to fix. Any ideas?

7 Years
Discussion Span
Last Post by Wolfgan

TLabel that can not do. Tsf need to use the DrawText API function with the keys: DT_CENTER + DT_VCENTER + DT_SINGLELINE
Pre TRect specify where you want to write an inscription.
If you do not know what size is needed, then add key DT_CALCRECT. When this key TRect will be calculated but the inscription will not be bred. That would bring the inscription should call the second time, without the key.


Ok what you just said is completly new to me again lol, thanks very much for your help though :D.

You know how I learn best, is if you zip up a example file.

The screen I will be using is for my computer screen at College, it has a screen resolution of 1280x1024 but just incase it would be nice if you can use DT_CALCRECT. Just make it so I can show a label in the middle of the screen and 180px from the top.

If you could do that then once again I'm going to be ever so greatful :D :D :D. Like last time, your help was much appreciated :).


Quite simply, I do not understand the difficulty. Moreover, this effect can be dobitsya and in other ways. The easiest to use the component TPanel. Another set of TLabel property AlignWithMargin: = true and set the necessary margin Margin.Top: = n.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.