center the Form's caption text  
Author Message
Jassim Rahma





PostPosted: Windows Forms General, center the Form's caption text Top

how can i center the form's caption text in C# 2005




Windows Forms14  
 
 
Peter Ritchie





PostPosted: Windows Forms General, center the Form's caption text Top

You can't set the format of a form's caption text to "centered".

You would have to process one of the Size events and calculate how many spaces to insert in front of the text you want to display to center it.

Not recommended; people expect they're caption to be left justified in LTR locales and right-justified in RTL locals.



 
 
MarcD





PostPosted: Windows Forms General, center the Form's caption text Top

Not easily. I believe it involves overriding the WndProc method of your form, and handling certain NMH messages

 
 
kadabba





PostPosted: Windows Forms General, center the Form's caption text Top

Lousy but easy(Edited: Not easy if you want all the functionality of the windows) solution:

Create a base form and change the FormBorderStyle to None, then you have to create the Form caption Area, Control Box  and border yourself, then you can do whatever you want.

Remember if you want a fully functional form then you will need to write Minimize, Maximize and Move the form yourself.


 
 
Peter Ritchie





PostPosted: Windows Forms General, center the Form's caption text Top

Lousy but easy solution:

Create a base form and change the FormBorderStyle to None, then you have to create the Form caption Area, Control Box and border yourself, then you can do whatever you want.

Remember if you want a fully functional form then you will need to write Minimize, Maximize and Move the form yourself.

Not very easy if you want to support XP's themed AND classic mode, plus other "current" versions of Windows.



 
 
kadabba





PostPosted: Windows Forms General, center the Form's caption text Top

You are right! But you should agree that is lousy!
 
 
cablehead





PostPosted: Windows Forms General, center the Form's caption text Top

Here is a VB version if you want to convert it:

http://www.ostrosoft.com/vb/projects/center.asp