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 SkipVought 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 terminate button in the control box

Status
Not open for further replies.

Fosters

Programmer
Mar 6, 2001
16
0
0
GB
anyone know how?
 
If your QueryUnload function put the following:

Cancel = True

That will stop your application from quitting. You might want to have a global boolean variable which you check first so that someone CAN quit your application.

Chaz
 
I already found a bit of code, but thanks for your reply. Here's what I did, if you are interested...

Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, ByVal bRevert As Long) As Long

Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long

Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&

Form code----------------
Dim hSysMenu As Long
Dim nCnt As Long

'First, show the form
Me.Show

'Get handle to our form's system menu
'(Restore, Maximize, Move, close etc.)
hSysMenu = GetSystemMenu(Me.hwnd, 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

RemoveMenu hSysMenu, nCnt - 2, _
MF_BYPOSITION Or MF_REMOVE 'Remove the seperator

DrawMenuBar Me.hwnd
'Force caption bar's refresh. Disabling X button

Me.Caption = "Try to close me!"
End If
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top