Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Lock userform position

Is it possible to lock the position of a userform to prevent users from dragging it around the screen?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Lock userform position

you can display it without the caption bar and then it can't be moved.
Download Formfun.zip from Stephen Bullen's site and it demonstrates many
options you can do with a userform. Code is accessible.

http://www.BMSLtd.ie/Excel.Default.htm

--
Regards,
Tom Ogilvy

"Newbie" wrote in message
...
Is it possible to lock the position of a userform to prevent users from

dragging it around the screen?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Lock userform position

Hi Newbie,
You can test:
Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function GetSystemMenu& Lib "user32" _
(ByVal hwnd&, ByVal bRevert&)
Private Declare Function DeleteMenu& Lib "user32" _
(ByVal hMenu&, ByVal nPosition&, ByVal wFlags&)

Private Sub UserForm_Initialize()
Me.StartUpPosition = 0
Me.Left = 50: Me.Top = 90
Dim hwnd&, hSysMenu&
hwnd = FindWindow(vbNullString, Me.Caption)
hSysMenu = GetSystemMenu(hwnd, False)
DeleteMenu hSysMenu, &HF010&, &H0&
End Sub

MP

"Newbie" a écrit dans le message de
...
Is it possible to lock the position of a userform to prevent users from dragging

it around the screen?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Lock userform position

Re Newbie,
Or if you prefer (to envisage a button to close the userform):
Private Declare Function FindWindowA& Lib "User32" _
(ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLongA& Lib "User32" _
(ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)

' Necessary button to close userform
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.StartUpPosition = 0
Me.Left = 50: Me.Top = 90
Dim hWnd As Long, exLong As Long
hWnd = FindWindowA(vbNullString, Me.Caption)
SetWindowLongA hWnd, -16, &H84400080
End Sub

MP


"Newbie" a écrit dans le message de
...
Is it possible to lock the position of a userform to prevent users from dragging

it around the screen?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm position Steve Excel Discussion (Misc queries) 1 August 26th 07 04:50 AM
How can I lock the position of a textbox? Cynthia Excel Discussion (Misc queries) 1 January 12th 07 03:24 PM
Userform Position Pete Excel Programming 4 February 20th 05 12:01 AM
freeze/lock form position L Mehl Excel Programming 0 May 17th 04 10:57 PM
UserForm position Tim Excel Programming 2 February 12th 04 03:20 PM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"