Removing Titlebar from Word 2000 UserForm

N

Nam

How can we do the above? Setting the BorderStyle property to 0 does not work
for Word 2000 UserFrom.

Thanks,
Nam
 
D

Dawn Crosier

Setting the Caption to an empty string is not sufficient? Or are
you attempting to get rid of the "Close Form" button?

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.

How can we do the above? Setting the BorderStyle property to 0
does not work
for Word 2000 UserFrom.

Thanks,
Nam
 
N

Nam

I need to remove the entire Blue title bar not just the caption. You can do
it in VB6 Form by setting the BorderStyle property to 0. It doesn't work on
Word 2000 UserFrom.
 
K

Karl E. Peterson

Nam said:
I need to remove the entire Blue title bar not just the caption. You
can do it in VB6 Form by setting the BorderStyle property to 0. It
doesn't work on Word 2000 UserFrom.

You'll likely need to use the API to twiddle that UserForm's style bits. Take a look
at the code at http://vb.mvps.org/samples/FormBdr to get an idea. In
CFormBorder.cls, I provide a way to toggle lots of "read only at runtime" properties,
one of which would control whether that titlebar is visible:

Public Property Let Titlebar(ByVal Value As Boolean)
' Set WS_CAPTION On or Off as requested.
Call FlipBit(WS_CAPTION, Value)
End Property

Public Property Get Titlebar() As Boolean
' Return value of WS_CAPTION bit.
Titlebar = CBool(Style And WS_CAPTION)
End Property

That class will need a little tweaking to work with UserForms, but probably not a
lot.

Later... Karl
 
N

Nam

I found the following post by Nathan Taylor on
autodesk.autocad.customization.vba (Feb 18, 2004). His following solution
worked for me and I would like to thank him for this:

*****************From Nathan Taylor**********************
Here are a couple of subs I use to remove the titlebar altogether or just
disable the close cross & right clicking the titlebar and selecting close.
Call the appropriate one from the userform Activate event.

Option Explicit
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal
uPosition As Long, ByVal uFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As
Long
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

Public Sub DisableClose()
Dim hwnd As Long
Dim hMenu As Long
hwnd = GetActiveWindow()
hMenu = GetSystemMenu(hwnd, 0)
Call RemoveMenu(hMenu, 6, &H400)
Call RemoveMenu(hMenu, 5, &H400)
Call DrawMenuBar(hwnd)
End Sub

Public Sub Remove()
Dim hwnd As Long
Dim dwNewLong As Long
hwnd = GetActiveWindow()
dwNewLong = GetWindowLong(hwnd, -16)
dwNewLong = dwNewLong And Not &HC00000
Call SetWindowLong(hwnd, -16, dwNewLong)
DrawMenuBar hwnd
End Sub
**********************
Thanks,
Nam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top