Verschieben einer UserForm verhindern

28.03.2002


Um eine Userform zu fixieren benötigt man eine API-Routinen
Dies funktioniert über das Handle der Userform.
Da es hierfür keine Eigenschaft gibt, wie es im reinen Visual Basic
der Fall ist (.hwnd), muss man sich mittels FindWindow und
der UserForm-Caption helfen:

   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 RemoveMenu Lib "user32" _
     (ByVal hMenu As Long, ByVal nPosition As Long, _
     ByVal wFlags As Long) As Long
   Private Sub FixWindow(hWnd As Long)
      Dim SysMenu As Long
      Dim Ret As Long
      SysMenu = GetSystemMenu(hWnd, False)
      Ret = RemoveMenu(SysMenu, &HF010&, &H0&)
   End Sub
   Private Sub UserForm_Activate()
      FixWindow FindWindow(vbNullString, Me.Caption)
   End Sub