Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hide exit and colse from file menu?

Posted on 2002-04-18
4
Medium Priority
?
156 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 150 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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