Bonjour,
Aprés avoir appliqué l'instruction 'Application.ScreenUpdating=False',
y a t-il un moyen pour empêcher de déplacer une UserForm à l'aide de la
souris.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Daniel.C
Bonjour. J'ai trouvé ce code sur Internet. Ca fonctionne, mais je n'ai pas cherché à comprendre comment : 1. dans le code du userform (nommé UserForm1) :
Private Sub UserForm_Activate() lockPos End Sub
2. dans un module :
Option Explicit
Private Const MF_BYCOMMAND As Long = &H0& Private Const SC_MOVE As Long = &HF010 Private Const SC_SEPARATOR As Long = &HF00F
'USER32 Private Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function GetSystemMenu Lib "user32" ( _ ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function DrawMenuBar Lib "user32" ( _ ByVal hwnd 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 Sub UserForm_Activate() lockPos End Sub
Sub lockPos() Dim hWndForm As Long, hSysMenu As Long, nCnt As Long
hWndForm = FindWindow(vbNullString, UserForm1.Caption) If hWndForm Then hSysMenu = GetSystemMenu(hWndForm, False)
If hSysMenu Then RemoveMenu hSysMenu, SC_MOVE, MF_BYCOMMAND RemoveMenu hSysMenu, SC_SEPARATOR, MF_BYCOMMAND DrawMenuBar hWndForm End If End If
End Sub
Cordialement. Daniel
"José" a écrit dans le message de news: 470f1d8f$0$570$
Bonjour, Aprés avoir appliqué l'instruction 'Application.ScreenUpdatingúlse', y a t-il un moyen pour empêcher de déplacer une UserForm à l'aide de la souris.
Par avance merci. José
Bonjour.
J'ai trouvé ce code sur Internet. Ca fonctionne, mais je n'ai pas cherché à
comprendre comment :
1. dans le code du userform (nommé UserForm1) :
Private Sub UserForm_Activate()
lockPos
End Sub
2. dans un module :
Option Explicit
Private Const MF_BYCOMMAND As Long = &H0&
Private Const SC_MOVE As Long = &HF010
Private Const SC_SEPARATOR As Long = &HF00F
'USER32
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" ( _
ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hwnd 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 Sub UserForm_Activate()
lockPos
End Sub
Sub lockPos()
Dim hWndForm As Long, hSysMenu As Long, nCnt As Long
hWndForm = FindWindow(vbNullString, UserForm1.Caption)
If hWndForm Then
hSysMenu = GetSystemMenu(hWndForm, False)
If hSysMenu Then
RemoveMenu hSysMenu, SC_MOVE, MF_BYCOMMAND
RemoveMenu hSysMenu, SC_SEPARATOR, MF_BYCOMMAND
DrawMenuBar hWndForm
End If
End If
End Sub
Cordialement.
Daniel
"José" <perez.jose@free.fr> a écrit dans le message de news:
470f1d8f$0$570$426a34cc@news.free.fr...
Bonjour,
Aprés avoir appliqué l'instruction 'Application.ScreenUpdatingúlse',
y a t-il un moyen pour empêcher de déplacer une UserForm à l'aide de la
souris.
Bonjour. J'ai trouvé ce code sur Internet. Ca fonctionne, mais je n'ai pas cherché à comprendre comment : 1. dans le code du userform (nommé UserForm1) :
Private Sub UserForm_Activate() lockPos End Sub
2. dans un module :
Option Explicit
Private Const MF_BYCOMMAND As Long = &H0& Private Const SC_MOVE As Long = &HF010 Private Const SC_SEPARATOR As Long = &HF00F
'USER32 Private Declare Function FindWindow Lib "user32" Alias _ "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function GetSystemMenu Lib "user32" ( _ ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function DrawMenuBar Lib "user32" ( _ ByVal hwnd 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 Sub UserForm_Activate() lockPos End Sub
Sub lockPos() Dim hWndForm As Long, hSysMenu As Long, nCnt As Long
hWndForm = FindWindow(vbNullString, UserForm1.Caption) If hWndForm Then hSysMenu = GetSystemMenu(hWndForm, False)
If hSysMenu Then RemoveMenu hSysMenu, SC_MOVE, MF_BYCOMMAND RemoveMenu hSysMenu, SC_SEPARATOR, MF_BYCOMMAND DrawMenuBar hWndForm End If End If
End Sub
Cordialement. Daniel
"José" a écrit dans le message de news: 470f1d8f$0$570$
Bonjour, Aprés avoir appliqué l'instruction 'Application.ScreenUpdatingúlse', y a t-il un moyen pour empêcher de déplacer une UserForm à l'aide de la souris.