Gå til innhold

Enable avslutt-knappen i VB 6.0


Anbefalte innlegg

Videoannonse
Annonse
Skrevet

Legg til følgende kode i øverst (dog under Option Explicit) i formkodevinduet:

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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long

 

Private Const MF_BYCOMMAND = &H0&

Private Const SC_CLOSE = &HF060&

 

Public Sub SetXState(Form As Form, bState As Boolean)

   

    Dim hMenu As Long

 

    ' Hent peker til formets menylinje

    hMenu = GetSystemMenu(Form.hwnd, blnState)

   

    ' Endre menyelement og oppdater

    RemoveMenu hMenu, SC_CLOSE, MF_BYCOMMAND

    DrawMenuBar Form.hwnd

 

End Sub

 

Deretter kan du "disable" X-tasten således:

SetXState Me, False
.

 

Det motsatte er opplagt nok slik:

SetXState Me, True
Skrevet
Legg til følgende kode i øverst (dog under Option Explicit) i formkodevinduet:
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 DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long

 

Private Const MF_BYCOMMAND = &H0&

Private Const SC_CLOSE = &HF060&

 

Public Sub SetXState(Form As Form, bState As Boolean)

   

    Dim hMenu As Long

 

    ' Hent peker til formets menylinje

    hMenu = GetSystemMenu(Form.hwnd, blnState)

   

    ' Endre menyelement og oppdater

    RemoveMenu hMenu, SC_CLOSE, MF_BYCOMMAND

    DrawMenuBar Form.hwnd

 

End Sub

 

Deretter kan du "disable" X-tasten således:

SetXState Me, False
.

 

Det motsatte er opplagt nok slik:

SetXState Me, True

6741526[/snapback]

Takk for hjelpen!

 

Fant det ut nå.

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...