Remove a Title Bar or None BorderStyle On MDI Form

Sometime we want to manipulate the entire screen appearance, without having to be limited by the title bar or status bar, if that's what you want, refer to the following reviews

On the reguler form this is very easy to do, we only have to set the property BorderStyle = 0 - None, but to remove Title Bar on MDI Form we need to call some API function.



Add an MDI Form to the project via Project -> Add MDI Form, and a Module from the menu Project -> Add Module

Double klik Module1, and type in the following 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

Private Const GWL_STYLE = (-16)
Private Const WS_BORDER = &H800000
Private Const WS_CAPTION = &HC00000

Public Sub MDINoBorder(ByRef nFormHWND As Long)
Dim sHandle As Long
On Error GoTo errMDINoBorder

sHandle = GetWindowLong(nFormHWND, GWL_STYLE)
sHandle = sHandle And Not WS_CAPTION
SetWindowLong nFormHWND, GWL_STYLE, sHandle

Exit Sub

errMDINoBorder:
  MsgBox "[" & Err.Number & "] - " & Err.Description, _
  vbExclamation, "MDI No Border Error"
End Sub

And then double click the MDIForm1, and type in the following code :

Private Sub MDIForm_Activate()
  MDINoBorder Me.hwnd
End Sub

Run the project by pressing the F5 key, and see the result now MDIForm on your project does not have a Title Bar.


Good luck.

Be My Friend On Facebook

Share this

Related Posts

Previous
Next Post »

1 comments:

comments
Anonymous
March 11, 2015 at 4:00 AM delete

Hey there, You have done a great job. I will certainly digg it and personally recommend to my friends.
I am confident they'll be benefited from this site.


Also visit my web blog :: cheap jordan

Reply
avatar