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
Printable View
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
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.
What don't you want visible...the caption or the title bar?
Hiya
Thats exactly what i want to do.
I dont suppose you know the name of the api?
Sarah
VB Code:
Private Sub Form_Resize() If Me.WindowState = vbNormal Or Me.WindowState = vbMaximized Then Me.Caption = "" Else Me.Caption = "Form1" End If End Sub
Doing this would mean the caption is invisble when the form is maximized!Quote:
Originally posted by Hack
VB Code:
Private Sub Form_Resize() If Me.WindowState = vbNormal Or Me.WindowState = vbMaximized Then Me.Caption = "" Else Me.Caption = "Form1" End If End Sub
Check out here, this question has actually already been answered.
http://www.vbforums.com/showthread.p...askbar+caption
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.Quote:
Originally by Grimfort
Doing this would mean the caption is invisble when the form is maximized!
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?
Number OneNumber Two: Interesting Question. Let me work on it.VB Code:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long 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 Private Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME Private Const GWL_STYLE = (-16) Private Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOZORDER = &H4 Private Function DisplayCaption(ByVal IsDisplayed As Boolean) As Boolean Dim MyStyle As Long MyStyle = GetWindowLong(Me.hwnd, GWL_STYLE) If IsDisplayed Then MyStyle = MyStyle Or WS_CAPTION Else MyStyle = MyStyle And Not WS_CAPTION End If If SetWindowLong(Me.hwnd, GWL_STYLE, MyStyle) Then If MyStyle = GetWindowLong(Me.hwnd, GWL_STYLE) Then DisplayCaption = True End If End If SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE End Function Private Sub Form_Load() 'i wrote this to be a toggle 'if you say DisplayCaption True it redisplay it DisplayCaption False End Sub
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:
Option Explicit Dim bresize As Boolean Dim bYDrag As Boolean Dim bXDrag As Boolean Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case Screen.MousePointer Case vbSizePointer, vbSizeWE, vbSizeNS bresize = True Case vbNormal bresize = False End Select End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then If bresize = True Then Select Case Screen.MousePointer Case vbSizeWE Me.Width = X Case vbSizeNS Me.Height = Y Case Else End Select End If Else If X >= Me.Width - 50 Or X = 0 Then bXDrag = True 'HORIZONTAL DRAG Else bXDrag = False End If If Y >= Me.Height - 50 Or Y = 0 Then 'VErTICAL DRAG bYDrag = True Else bYDrag = False End If If bYDrag And bXDrag Then Screen.MousePointer = vbSizePointer ElseIf bYDrag Then Screen.MousePointer = vbSizeNS ElseIf bXDrag Then Screen.MousePointer = vbSizeWE Else Screen.MousePointer = vbNormal End If End If End Sub
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. :)
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?
send it my way when you shovel all the crap out of my code :D and as of this you are at 8999 posts so for now i will say congrats on the 9kQuote:
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. :)