'Incollare queste dichiarazione in un modulo .bas:
Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Long, ByVal bRevert As Long) As Long Declare Function GetMenuItemCount Lib "user32" _ (ByVal hMenu As Long) As Long Declare Function DrawMenuBar Lib "user32" _ (ByVal hwnd As Long) As Long Declare Function RemoveMenu Lib "user32" _ (ByVal hMenu As Long, ByVal nPosition As Long, _ ByVal wFlags As Long) As Long Public Const MF_BYPOSITION = &H400& Public Const MF_REMOVE = &H1000& ' 'Incollare il seguente codice nel form ' Private Sub Form_Load() Dim hSysMenu As Long Dim nCnt As Long ' Mostra il form Me.Show ' Acquisisce l'handle del menu' di sistema ' (Ripristina, Ingrandisci, Sposta, Chiudi etc.) hSysMenu = GetSystemMenu(Me.hwnd, False) If hSysMenu Then ' Acquisisce il numero delle voci nel menu' di sistema nCnt = GetMenuItemCount(hSysMenu) If nCnt Then ' Il conteggio del menu' e' basato su 0 (0, 1, 2, 3...) RemoveMenu hSysMenu, nCnt - 1, _ MF_BYPOSITION Or MF_REMOVE RemoveMenu hSysMenu, nCnt - 2, _ MF_BYPOSITION Or MF_REMOVE ' Rimuove il separatore DrawMenuBar Me.hwnd 'Forza il ridisegno della barra del titolo, disabilitando 'la X Me.Caption = "Prova a chiudermi!" End If End If End Sub Questo trucchetto dimostra come disabilitare la X sulla barra titolo del form. Questo viene fatto rimuovendo la voce 'Chiudi' nel menu' di sistema del form. Funziona bene, finche' non si vuole riabilitare la X. |