![]() |
disable the windows 'minimize' & 'file exit' buttons
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 |
disable the windows 'minimize' & 'file exit' buttons
I think you mean the close window icon.
If that is what you mean you can enter this routine: Please not this is one of many ways. Private Sub UserForm_QueryClose(iCancel As Integer, iCloseMode A Integer) If iCloseMose = vbFormControlMenu Then iCancel = True End If (Code written by John Green not me by the way) -- Message posted from http://www.ExcelForum.com |
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 |
All times are GMT +1. The time now is 06:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com