Índice

Solución 19.3 Ocultar la cruz de cierre de los formularios personalizados

En la zona de declaraciones del formulario:

Private Declare PtrSafe Function GetWindowLongA Lib "user32" _  
(ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr  
  
Private Declare PtrSafe Function SetWindowLongA Lib "user32" (ByVal hwnd As _ 
LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr  
  
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _ 
(ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr

Comentario

Las tres declaraciones siguientes son obligatorias.

En la zona del código del formulario:

Private Sub UserForm_Initialize()   
   
    Dim hwnd As LongPtr  
    Dim lngStyle As LongPtr  
    ’========================================================  
    ’ La función FindWindow recupera el handle (entero largo)   ...