C
chrisdarl
Hi, I am wanting to keep the possition of the userform the same and i
was thinking of a code to add that when the mouse moves or is clicked
the left & top possition is checked and if left is not 350 and top is
not 115 then they are changed to that value.
I was thinking of something like:
If Me.Left >= 350 Or Me.Left <= 350 Or Me.Top >= 115 Or Me.Top <= 115
Then
Me.Left = 350
Me.Top = 115
End If
proberly completely wrong but can anyone give me any ideas as im not
sure where to put this?
I've tried Private sub userform_click() ect.
Also
I have tried the code below to stop the user moving the userform but i
recieve comment errors?
Option Explicit
Private Const MF_BYPOSITION As Long = &H400
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName _
As String) As Long
Private Sub UserForm_Initialize()
Dim lHandle As Long, lCount As Long
On Error Resume Next
lHandle = FindWindowA(vbNullString, Me.Caption)
If lHandle <> 0 Then
For lCount = 1 To 6
DeleteMenu GetSystemMenu(lHandle, False), 0, MF_BYPOSITION
Next lCount
End If
End Sub
Can anyone give me any ideas on what im doing wrong?
Thanks Chris.
was thinking of a code to add that when the mouse moves or is clicked
the left & top possition is checked and if left is not 350 and top is
not 115 then they are changed to that value.
I was thinking of something like:
If Me.Left >= 350 Or Me.Left <= 350 Or Me.Top >= 115 Or Me.Top <= 115
Then
Me.Left = 350
Me.Top = 115
End If
proberly completely wrong but can anyone give me any ideas as im not
sure where to put this?
I've tried Private sub userform_click() ect.
Also
I have tried the code below to stop the user moving the userform but i
recieve comment errors?
Option Explicit
Private Const MF_BYPOSITION As Long = &H400
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName _
As String) As Long
Private Sub UserForm_Initialize()
Dim lHandle As Long, lCount As Long
On Error Resume Next
lHandle = FindWindowA(vbNullString, Me.Caption)
If lHandle <> 0 Then
For lCount = 1 To 6
DeleteMenu GetSystemMenu(lHandle, False), 0, MF_BYPOSITION
Next lCount
End If
End Sub
Can anyone give me any ideas on what im doing wrong?
Thanks Chris.