How to center the title of a form ?


P

Polaris

Hi:

I'm programming Windows forms with C#. By default, all windows title is
left-aligned, just wonder if there is a way to make the title center-aligned
on the Windows title bar?

Thanks in advance!
Polaris
 
Ad

Advertisements

J

Jon Skeet [C# MVP]

I'm programming Windows forms with C#. By default, all windows title is
left-aligned, just wonder if there is a way to make the title center-aligned
on the Windows title bar?

I don't believe this is possible - it's just the way Windows is. Apart
from anything else, if you did this it would make your app look
different to every other application I've ever seen. Consistency is a
good thing.

Jon
 
K

Kerem Gümrükcü

Hi Jon,

in regular ways this wont work, but when you hook into
the forms message queue, then you can trap e.g. WM_NC*
Messages and Draw the Text into the caption for the
form with gdi functions and modify it with the form resizing
events or any appropriate functions/messages...but NOT
recommended!

But this is something very uncommon and i would
consider it as a strange thing,...

Much better solution would be a user defined control
or window placed on a form without the caption bar
that emulates the system caption bars functionallity,...

Thats what i would recommend,...

Regards

Kerem

-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 
J

Jon Skeet [C# MVP]

in regular ways this wont work, but when you hook into
the forms message queue, then you can trap e.g. WM_NC*
Messages and Draw the Text into the caption for the
form with gdi functions and modify it with the form resizing
events or any appropriate functions/messages...but NOT
recommended!

Ick! An alternative and slightly simpler idea would be to measure the
size of the text (knowing the font size) and insert an appropriate
number of spaces at the start of the title to get "rough" centering :)
But this is something very uncommon and i would
consider it as a strange thing,...

Much better solution would be a user defined control
or window placed on a form without the caption bar
that emulates the system caption bars functionallity,...

Thats what i would recommend,...

What I'd recommend is sticking with the look and feel that users are
already used to. Why make things different? I *could* decide to make
my app save with Ctrl+N and create a new document with Ctrl+S, but
it's a bad idea :)

Jon
 
M

Michael Nemtsev [MVP]

Hello Polaris,

Just to support Jon. I've never understand why peoply trying to change the
standard windows? like title bar and etc? It never brings more functionality
or makes your app more pleasant.

Just try to contcentrate on your app functionality rather than on this glare
stuff


---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


P> Hi:
P>
P> I'm programming Windows forms with C#. By default, all windows title
P> is left-aligned, just wonder if there is a way to make the title
P> center-aligned on the Windows title bar?
P>
P> Thanks in advance!
P> Polaris
 
K

Kerem Gumrukcu

Hi Michael,
Just to support Jon. I've never understand why peoply trying to change the
standard windows? like title bar and etc? It never brings more
functionality or makes your app more pleasant.
Just try to contcentrate on your app functionality rather than on this
glare stuff

Damn right!

Regards

Kerem

--
-----------------------
Beste Grusse / Best regards / Votre bien devoue
Kerem Gumrukcu
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 
Ad

Advertisements

M

Mattias Sjögren

Jon,
Apart
from anything else, if you did this it would make your app look
different to every other application I've ever seen.

FWIW, Microsoft Office 2007 does exactly this.

Of course, when Office does it, people don't see it as inconsistency
but as innovation. And it becomes the OS standard a few years later.

Consistency is a good thing.

Agreed!


Mattias
 
Ad

Advertisements

M

Michael Nemtsev [MVP]

Hello Mattias,

I wonder how much $ MS spent on usability engineers to introduce this Ribbon
stuff :)
I suppose it's not just the idea of single developer "lets put this button
there"

MS> Jon,
MS>MS> FWIW, Microsoft Office 2007 does exactly this.


---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top