How do you align the caption of the form on the title bar to the right rather the left?
Printable View
How do you align the caption of the form on the title bar to the right rather the left?
With difficulty. You'll need to get the non-client area DC and paint it yourself.
You could make a fake-titlebar with a label, which you set align to the right
I'll post an example project in a few minutes.
Or you could just space the title over.
Until the user resizes the form :(.
it might take a while, but you could write a little function that adds spaces to the title bar depending on the width of the form,
I tried it for about 5 min. but I gave up... not cuz its too hard, but because um.... too lazy :)
ok in my VB i can use:
and this works great, coz in my language we start writing from right to left, not like english, thats why we use this...don't u have these property in ur VB???Code:Form1.RightToLeft = True
On my UK English machine, it has the property, but is set to False by default. If I then change it to True, it instantly changes back to False. Bit annoying really.
Here's a very rough example, which demonstrates right alignment of the title, and it's the same example I'm using for another thread, so it has some extra bits in:
http://www.parksie.uklinux.net/newtitle.zip
actually this is what should happen, coz your version doesn't support RightToLeft property, coz u only use English in ur windows, but my version supports Arabic and English, thats why it works here, but if u have any another version Which support RightToLeft then it will work, i think Arabic, Hebrew, Urdo and Persian the only languages which write from Right to left, and i think in thses versions of windows u have every thing twice, i mean like Text Boxes and Combo Boxes and every thing, one of then left to right, and the other is right to left, and u have defferent DLL files for every one of them, or defferent call, i don't know but this is what i think....
I think that the same controls just support the extra property, then display the text in a different way. The change is probably somewhere else in Windows.
Thanks for replying. I am not looking for right align. I want to be able to place text on the left, center, and the right. I used space(20) but one different computer it comes out different.
Any ideas?
You can use a PictureBox in place of the TitleBar.
Code:Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const SC_MOVE_EX = &HF012
Const WM_SYSCOMMAND = &H112
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MOVE_EX, 0
End If
End Sub
You code didn't do anything Megatron or am I running something wrong.
Thanks Megatron.
The code uses a PictureBox as a Titlebar. Set the Form's Caption to a blank string and set the ControlBox to False. Add a Picturebox to the Form, set the Align to 1-Align Top and then try it.
Change the constants to:
SC_MOVE_EX = 2
WM_SYSCOMMAND = &HA1
This should do it.