How to gray out the "X" main close appl icon (1 Viewer)

Bobby1st

Registered User.
Local time
Today, 04:19
Joined
Jan 5, 2007
Messages
62
This is a continuation of my thread posted 2/21/08, solved by Rolaaus. Reference: Log In and Log Out Information Save.

The Log Out is now working, saving the posted date-time information only when the exit button on the main menu is selected.

On the main menu form properties, the Close Button is set to No and force the use of the Exit button on the form. I did not utilized the On-Close properties or the visible = False, because it might create more problem for me to when open/closing lots of forms and reports.

The issue and how best fix it.:
When another open_form is called, there's no "X" icon to use as exit, however, when open_report is called there are two "X" icons, one for the report and the other the application exit, when use, it by-pass my script to log the Date-Time value. How and where will I be able to gray out the application "X" button?

Thanks
 

KeithG

AWF VIP
Local time
Today, 01:19
Joined
Mar 23, 2006
Messages
2,592
Paste the below code into a new module

Code:
Public Declare Function GetSystemMenu Lib "user32" _
                                      (ByVal Hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function DeleteMenu Lib "user32" _
                                   (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal Hwnd As Long) As Long



Public Sub DisableX(Handle As Long)
    Hwnd = Handle
    Dim hMenu As Long
    hMenu = GetSystemMenu(Hwnd, 0&)
    If hMenu Then
        DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND  'Disable the Close button
        DrawMenuBar (Hwnd) 'Repaint the MenuBar
    End If
End Sub


Then call the sub from the above code to disable the X button. Like below

Code:
Call DisableX(Application.hWndAccessApp)
 

Bobby1st

Registered User.
Local time
Today, 04:19
Joined
Jan 5, 2007
Messages
62
KeithG,
I tried diff. ways but I am getting variables not defined. it can't recognized the Hwnd; hmenu; SC_Close. I tried declaring a Dim, didn't work. I copied it exactly as posted.


RuralGuy, since the issue is the same maybe I my missing the user32? I don't know that.

Thank you.
 

Users who are viewing this thread

Top Bottom