Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aligning text on a form 2

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
GB
I have recently migrated to Visual FoxPro version 6 and want to know if it is possible to centre text within a form. I can't find a property for the alignment of text. Thanks for your help.
 
Labels, Textboxes etc have exactly that property: Alignment.
This is to align the value/caption within the objects size. So to center a text of a label on the form level, make that label as wide as the form and set it's alignment to center the caption and perhaps turn on wordwrap, if the text is multiline.

If you want that for resizable forms, too, go to VFP9, as that offers anchoring objects to form sides, and thus will enable to keep a text centered. In VFP6 you will need to program something in a resize event.

Welcome to windows forms. If you're used to exclusively using a dos screen only for your app, this is a shared world and you don't have full control over the size of a users screen. So you have to layout for shared access so to say. The easiest is to use fixed size forms and make the layout for them, making a certain minimum screensize the requirement.

Bye, Olaf.

 
Thanks Olaf this works OK. What about centering objects though.
There doesn't seem to be any property to help with this. I was trying to centre a command button but had to use own judgement.
 
Craig has a point, too

Even Window Title Bars don't have centered titles. But indeed web pages Headers of Text Do have centered h1,2,3,... tags. Both layouts can apply, so it all depends on the context.

Bye, Olaf.
 
Centering text on a form is not really done in a Windows app. It's harder for the user to read as their eyes keep moving to a different place on the screen to find the beginning of the line

But it's not unusual to center headings or buttons on a form.

Tamar
 
Thanks to you all. I was initially trying centre 2 lines of text which were Heading and sub heading.
 
@Olaf: Web UI standards are different that Windows. IMO, many web UI standards actually make things more difficult for the user vs. Windows standards. For example, in Windows, you left alight field labels, making it easier to read down a column of them and find the one you want. In Web, you right-align, so the line has a jagged left margin.

Craig Berntson
MCSD, Visual C# MVP,
 
Craig,

while you're right I was not talking of html forms when thinking about header tags. In the end it's a matter of taste how you position controls. Messagebox has the centered ok button, it's not that unusual, like Tamar says.

Looking at the forms of my apps there is not a concept I did apply all the time. Tastes are changing through time, not only in regard to sunken 3d look vs. flat look of controls (Win 3.x/95 vs XP and later).

In winforms I also often do right align label captions left of editable controls. This pulls the caption + control together. Caption ending with a colon and all colons aligned.

But I do left align text in lists/columns, it's true that is better readable. I think it's mainly the colons in captions, that make their left aligned layout look cluttered, while actually a list of captions also is better readable left aligned.

Bye, Olaf.
 
For what it's worth (not much, probably), I see absolutely nothing wrong with centering a heading on a VFP form - if doing so improves the appearance. After all, you might center the heading on a printed page; why should that be different?

I wouldn't want to center all the controls, but I'd have no problem in centering the main heading.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
For what it's worth? Maybe layout isn't a main topic for both development and usability also has more important parts.

I agree a heading is not wrong centered, but if we once again talk about the windows title bar, if you'd center that the task bar entry of an app would get unreadable. And if the title bar heading is left aligned, I'd also opt for a left alignment of a heading within the form canvas.

It's all a matter of taste.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top