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