Solved

Hide exit and colse from file menu?

Posted on 2002-04-18
4
149 Views
Last Modified: 2010-05-02
In the comments from Z_Beeblebrox, in question http://www.experts-exchange.com/questions/Q.20195631.html,
he refers to a link where you can inactivate the "X" (close) button in an application. (http://www.allapi.net/tips/tip060.SHTML).
I tried this for other running applications, and it works.
But now the user can still use the "Close" and "exit" from the "File" menu.
How can I suppres or inactivate this options????
0
Comment
Question by:theo kouwenhoven
  • 3
4 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
ID: 6952522
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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
Private Sub Form_Load()
    Dim hSysMenu As Long, nCnt As Long
    ' 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
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6952525
That code is from www.allapi.net. It disables close button and hide exit menu also.
add an unload me statement in form click event or you could not close it!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6954386
Why did you punish me with "B" grade?
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 6954626
Sorry,

I even can't remember that I clicked a,b or c.
on the moment I clicked the submit button I already was wondering why I didn't got a message.

Nex time I will give you the full credits.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question