|
-
Jan 5th, 2006, 09:18 PM
#1
[RESOLVED] Remove Title Bar Off Of Form Using API's
I just want to remove the titlebar of a form using API's, yet still be able to keep the black boarder around the form. Setting the Borderstyle to 0 - None removes both, and I don't want that. Any ideas on how I can pull this off?
-
Jan 5th, 2006, 09:36 PM
#2
Re: Remove Title Bar Off Of Form Using API's
Set the form border style to 1 - Fixed Single then remove the form caption and set the form Control Box to False.
-
Jan 5th, 2006, 09:37 PM
#3
Re: Remove Title Bar Off Of Form Using API's
This code works, the only problem is it change the border color, in my case is becomes gray, when it should be blue.
'IN A MODULE
VB Code:
'Remove Title Bar
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public 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 GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOSIZE = &H1
Public Sub Form_RemoveTitleBar(f As Form, ShowTitle As Boolean)
Dim Style As Long
' Get window's current style bits.
Style = GetWindowLong(f.hwnd, GWL_STYLE)
' Set the style bit for the title on or off.
If ShowTitle Then
Style = Style Or WS_CAPTION
Else
Style = Style And Not WS_CAPTION
End If
' Send the new style to the window.
SetWindowLong f.hwnd, GWL_STYLE, Style
' Repaint the window.
SetWindowPos f.hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE
End Sub
FORM:
VB Code:
Private Sub Form_Load()
Form_RemoveTitleBar Me, True 'Remove
Form_RemoveTitleBar Me, False 'Return
End Sub
-
Jan 5th, 2006, 09:58 PM
#4
Re: Remove Title Bar Off Of Form Using API's
To jcis: Crap, it still removed the border. And you may wanna fix your code cause False removed it, and True made it stay. 
To Lintz: I'm cannot do that like I said cause I'm just wanting to remove the titlebar, not the border and titlebar. The border must stay somehow.
-
Jan 5th, 2006, 10:03 PM
#5
Re: Remove Title Bar Off Of Form Using API's
It doesn't remove the border, you can see the Form is still resizable, it removes the controlbox, the controlbox is not only the titlebar, its also that colored line that houses the Form.
-
Jan 5th, 2006, 10:04 PM
#6
Re: Remove Title Bar Off Of Form Using API's
The black border is still visible using my code.....
-
Jan 5th, 2006, 10:07 PM
#7
Re: Remove Title Bar Off Of Form Using API's
Jr, add a menu and make it's visibility false. Then take the caption and the control box away
-
Jan 5th, 2006, 10:08 PM
#8
Re: Remove Title Bar Off Of Form Using API's
|2eM!x, that's what I originally posted (without the invisible menu)
-
Jan 5th, 2006, 10:10 PM
#9
Re: Remove Title Bar Off Of Form Using API's
 Originally Posted by lintz
The black border is still visible using my code.....
Ohhhhh, I didn't remove the caption. Duh.
Ahhhh nutz, it's only a 2D border and not a 3D one. I guess my only solution is to draw the borders by hand using the Line() statement.
-
Jan 5th, 2006, 10:12 PM
#10
Re: Remove Title Bar Off Of Form Using API's
Nope, if you want it 3d, set BorderStyle = 2 (3d border and sizable)
-
Jan 5th, 2006, 10:14 PM
#11
Re: Remove Title Bar Off Of Form Using API's
Sweet!!! Thanks man.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|