Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default disable the windows 'minimize' & 'file exit' buttons

To disable MOve & Close try this

Option Explicit
'////////////////////////////////////////////////////////////
'// What you need to do is to Disable the System Menu itime
'// for the Move control.
'// The system menu or Control menu is the Dropdown list you
'// get when you Right click on the windows Top area or write
'// to Area that usually has the Window caption, in this case
'// the userforms Name caption. Std windows has six, Userforms
'// have 2 = Move & Close.
'// Intersetingly enought to disable the close button all you
'// need to add to this routine to Disable Move is to Loop
'// until you hit the close = 7 ? and NOT 6, this I believe
'// takes into account the instance where the Sytem menu has
'// a "Whats this button"
'////////////////////////////////////////////////////////////

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 nPosition As Long, _
ByVal wFlags As Long) _
As Long

Private Declare Function FindWindowA _
Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long

Private Const MF_BYPOSITION As Long = &H400

Private Sub UserForm_Initialize()
Dim lFrmHdl As Long, iCount As Integer
'// Ivan F Moala
'// http://www.xcelfiles.com

lFrmHdl = FindWindowA(vbNullString, Me.Caption)

If lFrmHdl < 0 Then
'// MF_BYCOMMAND
'//Indicates that uPosition gives the identifier of the menu item.

'//If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is
specified,
'//the MF_BYCOMMAND flag is the default flag.

'// MF_BYPOSITION
'//Indicates that uPosition gives the zero-based relative position
of the menu item.
'// ie 0,1,2,3 etc
'Exit Sub
'//Typical Windows has 6 menus
'//Restore, Move, Size, Minimise, Maximize, Close

For iCount = 0 To 6
RemoveMenu GetSystemMenu(lFrmHdl, False), 0, MF_BYPOSITION
Next iCount
End If

End Sub



"larryb" wrote in message ...
I can't remember what the 'outer' window menubar is
called. Isn't there a way I can disable this to prevent a
user from moving or closing the application?


Thanks in Advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
minimize and maximize buttons missing KR4d Excel Discussion (Misc queries) 8 October 9th 09 03:32 PM
Buttons for Minimize, Restore and Close missing from Workbook CharlieD Excel Discussion (Misc queries) 1 January 30th 08 06:06 PM
Disable Exit button on a UserForm Noemi Excel Discussion (Misc queries) 1 September 14th 06 09:37 PM
Exit buttons in excel Aidan[_3_] Excel Programming 1 January 23rd 04 03:17 PM
How to get Maximize and Minimize buttons on Userform TBA[_2_] Excel Programming 1 September 9th 03 08:13 PM


All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"