|
-
Mar 26th, 2007, 10:32 PM
#1
Thread Starter
Lively Member
[RESOLVED] Commandbutton to make form border invisible?
I want to make the border on a form invisible on the click of a command button, like msn live messenger does on the conversations windows. Any ideas?
Stevevb6
Last edited by Hack; Mar 30th, 2007 at 05:47 AM.
Reason: Added [RESOLVED] to thread title and green "resolved" checkmark
-
Mar 26th, 2007, 10:35 PM
#2
Re: Commandbutton to make form border invisible?
This should work for you (I think -- no copy of VB installed at the moment so I can't check if the property name is BorderStyle or not). I believe 0 is the value you're looking for -- but it could be 1 or 2. Look at the form's possible values for the BorderStyle property to find out which one it should be if this doesn't work for you. You'll be looking for the value titled "No border," or something similar.
vb Code:
Private Sub Command1_Click()
Me.BorderStyle = 0
End Sub
-
Mar 26th, 2007, 10:52 PM
#3
Thread Starter
Lively Member
Re: Commandbutton to make form border invisible?
i have tried that, i figured it would work but it does nothing...
-
Mar 26th, 2007, 11:54 PM
#4
Re: Commandbutton to make form border invisible?
Code:
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Sub Form_DblClick()
Unload Me
End Sub
Private Sub Form_Load()
Dim WinRectRgn As Long
Dim WinRndRectRgn As Long
'VB APIs work in pixels
Me.ScaleMode = vbPixels
'Cause i'm going to write something on the form
Me.AutoRedraw = True
'Me message
Me.Print "Double click to close form"
'Make a normal rectangular window - left, top, width, height
WinRectRgn = CreateRectRgn(5, 30, Me.ScaleWidth - 5, Me.ScaleHeight - 5)
'Make a rectangular window with rounded corners - left, top, width, height, X roundness, Y roundness
WinRndRectRgn = CreateRoundRectRgn(5, 30, Me.ScaleWidth - 5, Me.ScaleHeight - 5, 30, 30)
'Set the window region
'Comment as required
SetWindowRgn Me.hWnd, WinRectRgn, True 'Normal rectangle
'SetWindowRgn Me.hWnd, WinRndRectRgn, True 'Round rectangle
End Sub
You can also make the form round or have custom regions as required
-
Mar 27th, 2007, 12:00 AM
#5
Re: Commandbutton to make form border invisible?
I installed VB and tried it for myself. I guess you can't change the border properties after the form is initialized -- at least not without the use of an API, maybe. if you really want this, you could always make a clone of the look of the window menu naturally and then make a border-less form that just resized when pressing a button. if you built the program using Windows XP and ran it under Vista it would have a graphical menu that looked like it was from Windows XP, though.. so that method doesn't offer much flexibility. sorry, I can't really help you much here.
edit: I don't think the code posted above is exactly what you want, but after looking through it, I guess it might work. doesn't look very nice in Vista after redrawing the form and putting it back to the normal vista-ish look.
Last edited by kows; Mar 27th, 2007 at 12:07 AM.
-
Mar 27th, 2007, 02:11 AM
#6
Re: Commandbutton to make form border invisible?
check out Karl E Peterson's FormBdr example
-
Mar 27th, 2007, 06:24 AM
#7
Re: Commandbutton to make form border invisible?
True this
vb Code:
Option Explicit
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
Private Const GWL_STYLE = (-16)
Private Const SWP_FRAMECHANGED = &H20
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()
DisplayCaption False
End Sub
Private Sub Command1_Click()
DisplayCaption True
End Sub
-
Mar 29th, 2007, 02:29 PM
#8
Thread Starter
Lively Member
Re: Commandbutton to make form border invisible?
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
|