How can I disable the X on in Word 9.0(Near the maximize and Minimize buttons). I would also like to know how to disable the close option on the right-click Popup menu. Any help will be appretiated. Thanks in advance.
John
Printable View
How can I disable the X on in Word 9.0(Near the maximize and Minimize buttons). I would also like to know how to disable the close option on the right-click Popup menu. Any help will be appretiated. Thanks in advance.
John
Hiya,
Well there's no direct route for a Node to tell you what TYPE it is. What u could do is ask it who its Parent is? If on exists you get the associated key. If not, well then its a Root. Thats about all i can think of....
Cheers
Gaurav
John, this works for Word97 (should work fine for Word 2000):Code:Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_REMOVE = &H1000&
Private Sub Form_Load()
Dim hSysMenu As Long
Dim nCnt As Long
Dim lhwnd As Long
'Get Handle to MS Word
lhwnd = FindWindow(vbNullString, "Microsoft Word - Document1")
'Get Handle to its System Menu
hSysMenu = GetSystemMenu(lhwnd, False)
If hSysMenu Then
'Get System menu's menu count
nCnt = GetMenuItemCount(hSysMenu)
If nCnt Then
'Menu count is based on 0 (0, 1, 2, 3...)
RemoveMenu hSysMenu, nCnt - 1, _
MF_BYPOSITION Or MF_REMOVE
'Remove the Separator
RemoveMenu hSysMenu, nCnt - 2, _
MF_BYPOSITION Or MF_REMOVE
'Force caption bar's refresh. Disabling X button
DrawMenuBar Me.hwnd
End If
End If
End Sub