Results 1 to 13 of 13

Thread: Caption Bar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Newcastle,UK
    Posts
    66

    Caption Bar

    Hi,

    I would like to give the caption bar at the top of a form a title, but at the same time i do not want it to be visible.

    Does anyone know a way of doing this?

    Thanks in advance

    Sarah

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Im gussing you are using this for the taskbar title ?

    If so I think there is an API call to change that, and you can just leave your caption as blank.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Newcastle,UK
    Posts
    66
    Hiya

    Thats exactly what i want to do.

    I dont suppose you know the name of the api?

    Sarah

  4. #4
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160
    What don't you want visible...the caption or the title bar?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    How about...

    VB Code:
    1. Private Sub Form_Resize()
    2. If Me.WindowState = vbNormal Or Me.WindowState = vbMaximized Then
    3.    Me.Caption = ""
    4. Else
    5.    Me.Caption = "Form1"
    6. End If
    7. End Sub

  6. #6
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: How about...

    Originally posted by Hack
    VB Code:
    1. Private Sub Form_Resize()
    2. If Me.WindowState = vbNormal Or Me.WindowState = vbMaximized Then
    3.    Me.Caption = ""
    4. Else
    5.    Me.Caption = "Form1"
    6. End If
    7. End Sub
    Doing this would mean the caption is invisble when the form is maximized!

    Check out here, this question has actually already been answered.

    http://www.vbforums.com/showthread.p...askbar+caption

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Originally by Grimfort
    Doing this would mean the caption is invisble when the form is maximized!
    Correct. That is my understanding of her question. The only time a caption should be displayed is when the form is minimized. If that is incorrect, then my apologies.

  8. #8
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160
    Can you turn the title bar on and/or off at run time, or is this something the can only be done at design time?

    How would you resize a borderless form?

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Number One
    VB Code:
    1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    2. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    3. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    4.  
    5. Private Const WS_CAPTION = &HC00000          '  WS_BORDER Or WS_DLGFRAME
    6. Private Const GWL_STYLE = (-16)
    7. Private Const SWP_FRAMECHANGED = &H20        '  The frame changed: send WM_NCCALCSIZE
    8. Private Const SWP_NOMOVE = &H2
    9. Private Const SWP_NOSIZE = &H1
    10. Private Const SWP_NOZORDER = &H4
    11.  
    12. Private Function DisplayCaption(ByVal IsDisplayed As Boolean) As Boolean
    13.         Dim MyStyle As Long
    14.        
    15.         MyStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
    16.           If IsDisplayed Then
    17.              MyStyle = MyStyle Or WS_CAPTION
    18.           Else
    19.              MyStyle = MyStyle And Not WS_CAPTION
    20.           End If
    21.          
    22.           If SetWindowLong(Me.hwnd, GWL_STYLE, MyStyle) Then
    23.              If MyStyle = GetWindowLong(Me.hwnd, GWL_STYLE) Then
    24.                 DisplayCaption = True
    25.              End If
    26.          End If
    27.          
    28.          SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE
    29. End Function
    30.  
    31. Private Sub Form_Load()
    32. 'i wrote this to be a toggle
    33. 'if you say DisplayCaption True it redisplay it
    34. DisplayCaption False
    35. End Sub
    Number Two: Interesting Question. Let me work on it.

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    this sounded interesting so i thought i would try to do it.. but i don't have time really to mess with it... i got it to work for the right side and bottom side of the form.. not for the top and left...

    here this code may help you if you want to build off it or something

    VB Code:
    1. Option Explicit
    2. Dim bresize As Boolean
    3. Dim bYDrag As Boolean
    4. Dim bXDrag As Boolean
    5.  
    6.  
    7. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8.     Select Case Screen.MousePointer
    9.         Case vbSizePointer, vbSizeWE, vbSizeNS
    10.             bresize = True
    11.         Case vbNormal
    12.             bresize = False
    13.     End Select
    14. End Sub
    15.  
    16. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    17.     If Button = 1 Then
    18.         If bresize = True Then
    19.             Select Case Screen.MousePointer
    20.                 Case vbSizeWE
    21.                     Me.Width = X
    22.                 Case vbSizeNS
    23.                     Me.Height = Y
    24.                 Case Else
    25.             End Select
    26.         End If
    27.     Else
    28.         If X >= Me.Width - 50 Or X = 0 Then
    29.             bXDrag = True
    30.             'HORIZONTAL DRAG
    31.         Else
    32.             bXDrag = False
    33.         End If
    34.         If Y >= Me.Height - 50 Or Y = 0 Then
    35.             'VErTICAL DRAG
    36.             bYDrag = True
    37.         Else
    38.             bYDrag = False
    39.         End If
    40.        
    41.         If bYDrag And bXDrag Then
    42.             Screen.MousePointer = vbSizePointer
    43.         ElseIf bYDrag Then
    44.             Screen.MousePointer = vbSizeNS
    45.         ElseIf bXDrag Then
    46.             Screen.MousePointer = vbSizeWE
    47.         Else
    48.             Screen.MousePointer = vbNormal
    49.         End If
    50.     End If
    51. End Sub

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Found it. The sample code on this link will add a size grip, similar to the size grip on a status panel, to your form. This will allow you to resize the form, regardless of its borderstyle. So, if you have a borderless form, and still want to allow your users to resize the form, this code will make it happen.

    http://www.vbsquare.com/api/sizegrip/index2.html

    Having said that, however, I think I'll take what Matt posted, and see if I can finish it up.

  12. #12
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160
    God, I LOVE this forum. It is like having your own, world-wide, research staff.

    Thanks everyone. My questions were answered.

    SarahNcl: Did you get your question answered?

  13. #13
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by Hack
    Found it. The sample code on this link will add a size grip, similar to the size grip on a status panel, to your form. This will allow you to resize the form, regardless of its borderstyle. So, if you have a borderless form, and still want to allow your users to resize the form, this code will make it happen.

    http://www.vbsquare.com/api/sizegrip/index2.html

    Having said that, however, I think I'll take what Matt posted, and see if I can finish it up.
    send it my way when you shovel all the crap out of my code and as of this you are at 8999 posts so for now i will say congrats on the 9k

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