Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable the 'X' Close button

Status
Not open for further replies.

ChadUSB

Programmer
Mar 28, 2006
1
US
We are having problems with users closing attachmate without loggin out of the primary application first.

Is there a way to disable to 'X' while there is an active connection to a host?
 
This can be done with an API calls, I've never done this with Attachmate but it should work with any Windows application (starting with Win2k).
Code:
Public Const SC_CLOSE = &HF060
Public Const MF_BYCOMMAND = &H0
Declare Function GetActiveWindow Lib "user32" () As Integer
Public Declare Function GetSystemMenu Lib "user32" _
                                      (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public Declare Function DeleteMenu Lib "user32" _
                                   (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long

Public Function DisableX()
Dim tmp As Long
    tmp = GetActiveWindow()
    Dim hMenu As Long
    hMenu = GetSystemMenu(tmp, 0&)
    If hMenu Then
        DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND
        DrawMenuBar (tmp)
    End If
End Function


Public Function RestoreX()
Dim hMenu As Long
Dim tmp As Long
    tmp = GetActiveWindow()
    hMenu = GetSystemMenu(tmp, 1)
    DrawMenuBar (tmp)
End Function

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top