Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
API to disable X
Message
De
08/11/2002 09:59:33
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
API to disable X
Divers
Thread ID:
00720274
Message ID:
00720274
Vues:
41
Hello all, I am having trouble getting an API function call to work. When the X is clicked on the control box, my form closes, but my application stays in debugging mode, meaning the application is still running. I know it is because I have two threads running in the background that keep on running when the X is clicked. Below is the code I am using. Any suggestions. TIA.
    Inherits System.Windows.Forms.Form

    Dim NewForm As Form
    Public pclsThreadNotify As clsThreadNotify
    Public pclsThreadReceived As clsThreadReceived


    ' New Code
    Public Declare Function GetSystemMenu Lib "user32" ( _
                                       ByVal hwnd As Long, _
                                       ByVal bRevert As Long) As Long
    Public Declare Function GetMenuItemCount Lib "user32" ( _
                                       ByVal hMenu As Long) As Long
    Public Declare Function RemoveMenu Lib "user32" ( _
                                       ByVal hMenu As Long, _
                                       ByVal nPosition As Long, _
                                       ByVal wFlags As Long) As Long
    Public Declare Function DrawMenuBar Lib "user32" ( _
                                       ByVal hwnd As Long) As Long

    Public Const MF_BYPOSITION = &H400&
    Public Const MF_DISABLED = &H2&

In the form load

        Dim hMenu As Long, nCount As Long

        'Get handle to system menu
        hMenu = GetSystemMenu(Me.Handle.ToInt64, 0)

        'Get number of items in menu
        nCount = GetMenuItemCount(hMenu)

        'Remove last item from system menu (last item is 'Close')
        Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)

        'Redraw menu
        DrawMenuBar(Me.Handle.ToInt64)
Randy Belcher
AFG Industries, Inc.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform