* VB-CODE (3)
Tip 109: Modifying an MDI Form's Border Style

June 12, 1995

This article explains how you can create a multiple-document interface =
(MDI) form
that has a fixed border in a Microsoft(r) Visual Basic(r) application.

Retrieving and Setting a Form's BorderStyle
Every form you create when designing a Microsoft(r) Visual Basic(r) =
can have one of four border styles. Just set the form's BorderStyle =
property to
one of the following styles:
0 - None
1 - Fixed Single
2 - Sizeable
3 - Fixed Double

An MDI child form, however, does not have a BorderStyle property. But by =
using the
Microsoft Windows(r) GetWindowLong and SetWindowLong application =
interface (API) functions , you can change an MDI form's border style to =
a fixed
border style.
The GetWindowLong function retrieves information about the specified =
style attributes and the SetWindowLong function modifies the specified =
style attributes.

GetWindowLong requires only two arguments. The first argument is the =
window's handle. The second argument specifies the type of information =
you want
to retrieve, which is the style settings for the window.
After retrieving the window's current style settings, use the bitwise =
And Not
function to remove the WS_THICKFRAME attribute from the style settings =
Next, issue a call to the SetWindowLong function to set the new style =
for the specified window. This creates an MDI form that has a fixed =
border style.

Example Program
This program shows how to create an MDI form that has a fixed border. =
Run the
example program by pressing F5. The MDI form will be displayed with a =

 1. Create a new project in Visual Basic. Form1 is created by default.
 2. From the Insert menu, select MDI Form to create an MDI form. =
MDIForm1 is
    created by default.
 3. Set Form1's MDIChild property to True. Modify the size of this form =
so that
    it is smaller than the MDIForm1 form.
 4. Add the following Constant and Declare statements to the General =
    section of Form1 (note that each Declare statement must be typed as =
a single
    line of text):

Private Declare Function GetWindowLong Lib "User" (ByVal hWnd As =
Integer, ByVal
  nIndex As Integer) As Long
Private Declare Function SetWindowLong Lib "User" (ByVal hWnd As =
Integer, ByVal
  nIndex As Integer, ByVal dwNewLong As Long) As Long
Const GWL_STYLE =3D (-16)

Const WS_THICKFRAME =3D &H40000

 5. Add the following code to the Load event for MDIForm1 (note that the =
    line must be typed as a single line of code):

Private Sub MDIForm_Load()
    Dim CurStyle As Long
    Dim NewStyle As Long
    CurStyle =3D GetWindowLong(MDIForm1.hWnd, GWL_STYLE)
    NewStyle =3D SetWindowLong(MDIForm1.hWnd, GWL_STYLE, CurStyle And
       Not (WS_THICKFRAME))
End Sub

Additional References

"GetSystemMenu." (Development Library, Product Documentation, SDKs,
   Windows 3.1 SDK, Programmer's Reference, Volume 2: Functions)
Knowledge Base Q118376. "How to Lock a Form So It Cannot Be Moved."
Knowledge Base Q110393. "How to Remove Menu Items from a Form's =
Control-Menu Box."
Knowledge Base Q77930. "Modifying the System Menu of an MDI Child =
Knowledge Base Q71669. "Preventing an MDI Child Window from Changing =