Results 1 to 17 of 17

Thread: Align Form Title

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    How do you align the caption of the form on the title bar to the right rather the left?
    Mako Shark
    Great White

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    With difficulty. You'll need to get the non-client area DC and paint it yourself.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You could make a fake-titlebar with a label, which you set align to the right
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I'll post an example project in a few minutes.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Guest
    Or you could just space the title over.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Until the user resizes the form .
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Guest
    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

  8. #8
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241
    ok in my VB i can use:
    Code:
    Form1.RightToLeft = True
    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???

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241
    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....

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    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?
    Mako Shark
    Great White

  14. #14
    Guest
    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

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247

    Question

    You code didn't do anything Megatron or am I running something wrong.

    Thanks Megatron.
    Mako Shark
    Great White

  16. #16
    Guest
    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.

  17. #17
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Change the constants to:
    SC_MOVE_EX = 2
    WM_SYSCOMMAND = &HA1

    This should do it.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width