Drag userform window contents

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
Greets all!
todays obscure challenge is as follows.

I would like to display a large userform on a small screen. There will be a background image and a number of commandbuttons, but no other controls.

Can i use the API to attach scroll bars (preferably invisible) and then use the mouse to drag the entire contents of the form so the user can see the bit they want to use?

Or other suggestions?

TIA
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
challenge solved. easier than i thought. here's what I did (for interested parties)...

even works if the controls are pushed completely outside the range of the userform

Code:
Dim x1 As Single, y1 As Single

Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Application.Cursor = xlDefault      ' put a hand here
    DoEvents
    x1 = X: y1 = Y
End Sub

Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Application.Cursor = xlDefault
    If Button = 1 Then
        CommandButton1.Top = CommandButton1.Top - y1 + Y
        CommandButton1.Left = CommandButton1.Left - x1 + X
        CommandButton2.Top = CommandButton2.Top - y1 + Y
        CommandButton2.Left = CommandButton2.Left - x1 + X
        DoEvents
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top