How do I change the border style of a form during runtime?
Printable View
How do I change the border style of a form during runtime?
You can't - it's read only !
All the API calls I looked at allow you to add borders / rectangles around a window, but I don't think there's any way you can set this ! :(
Why do you need this ?
Although the MSDN says so, but you can change the border style fo a form at run time. Just call the statement changing the borderstyle of the form repeatedly for 3-4 times, and it will change the border style. I have done this using the inbuilt BorderStyle property of vb.
Sorry, it didnt work. I need this to create a floating/docking toolbar window like in MS-Office and VB
Doesn't this work
Click the Button 3 - 4 times one after the other.Code:'assuming that the initial BorderStyle was 2
Private Sub Command1_Click()
Form1.BorderStyle = 0
Form1.Refresh
End Sub
It does not work. In VB5, it even gives an error, and in VB6, nothing happens. Ther must be an API call 4 this!:confused:
Strange, I had VB6 and it worked for me.
if you want the api to do it, here it is:
;) ;) ;) ;) :p :p :p :) :) :)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
Const GWL_STYLE = (-16)
'choices For style
Const WS_SIZEBOX = &H40000 '2-sizeable
'don't have other consts
Private Sub Command1_Click()
Dim curstyle As Long, newstyle As Long
'retrieve the window style
curstyle = GetWindowLong(Me.hwnd, GWL_STYLE)
curstyle = curstyle Or WS_SIZEBOX
'will make fixed single/fixed dialog windows sizeable
'Set the New style
newstyle = SetWindowLong(Me.hwnd, GWL_STYLE, curstyle)
'refresh
Me.Refresh
End Sub
but if you want a floating, docking toolbar, do it the windows way with a class avalible from www.vbaccelerator.com