BorderStyle property for VB.Form 
Author Message
 BorderStyle property for VB.Form

One of the properties VB5 VB.Form object is BorderStyle.
In custom UserControl that I have built I need to maintain two similar
VB.Form objects (one with BorderStyle=vbBSNone and the other with
BorderStyle=vbSizable) because BorderStyle is READ-ONLY at run time.
It seems stupid to duplicate code and maintain two graphical forms, but I
haven't found another way.

Someone have a solution ?
Did VB6 will allow to change BorderStyle value at run time ?

Regards,



Mon, 16 Jul 2001 03:00:00 GMT  
 BorderStyle property for VB.Form
Hi Marc.  Give this a try:

'place the following code in a module

Public PreserveFormStyle As Long

Public Const GWL_STYLE = (-16)

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 MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X
As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
bRepaint As Long) As Long

'window styles for get/set window long
Public Const WS_CAPTION = &HC00000
Public Const WS_OVERLAPPED = &H0&
Public Const WS_THICKFRAME = &H40000

'call this first
Public Sub MakeBorderstyle_vbBSNone()
Dim L As Long

L = GetWindowLong(Me.hwnd, GWL_STYLE)

PreserveFormStyle = L

L = L And Not (WS_OVERLAPPED Or WS_CAPTION Or _
WS_THICKFRAME)

Call SetWindowLong(Me.hwnd, GWL_STYLE, L)

Call MoveWindow(Me.hwnd, _
Me.ScaleX(Me.Left, vbTwips, vbPixels), _
Me.ScaleY(Me.Top, vbTwips, vbPixels), _
Me.ScaleX(Me.Width - 10, vbTwips, vbPixels), _
Me.ScaleY(Me.Height - 10, vbTwips, vbPixels), True)

End Sub

'to set it back to sizable
Public Sub MakeBorderstyle_vbSizable()
Dim L As Long

L = GetWindowLong(Me.hwnd, GWL_STYLE)

Call SetWindowLong(Me.hwnd, _
GWL_STYLE, PreserveFormStyle)

Call MoveWindow(Me.hwnd, _
Me.ScaleX(Me.Left, vbTwips, vbPixels), _
Me.ScaleY(Me.Top, vbTwips, vbPixels), _
Me.ScaleX(Me.Width + 10, vbTwips, vbPixels), _
Me.ScaleY(Me.Height + 10, vbTwips, vbPixels), True)
End Sub

hth
galen


Quote:
>One of the properties VB5 VB.Form object is BorderStyle.
>In custom UserControl that I have built I need to maintain two similar
>VB.Form objects (one with BorderStyle=vbBSNone and the other with
>BorderStyle=vbSizable) because BorderStyle is READ-ONLY at run time.
>It seems stupid to duplicate code and maintain two graphical forms, but I
>haven't found another way.

>Someone have a solution ?
>Did VB6 will allow to change BorderStyle value at run time ?

>Regards,



Mon, 16 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Changing Form's BorderStyle property at run time but before form is loaded

2. TextBox .BorderStyle property at run-time

3. Setting BorderStyle property

4. Help: BorderStyle property don't work for subclassed Edit control

5. : BorderStyle property of text control

6. borderstyle property

7. Mapping BorderStyle property

8. Form BorderStyle and Icon

9. Repost: Form BorderStyle 0 and Icon

10. BorderStyle on MDI Forms

11. Changing a Forms BorderStyle as runtime.

12. Form BorderStyle bug?

 

 
Powered by phpBB® Forum Software