Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VBA Visual Basic for Applications (Microsoft) FAQ

VBA How To

Moving a VB window or VBA userform that doesn't have a title bar by taupirho
Posted: 29 Jun 04

A previous FAQ of mine shows how to remove the title bar from a userform or window. Great. But now you can't move the form/window ... or can you? Read on.

More API programming I'm afraid but the code is fairly short

Put the following code in the general declaration section

Private Declare Function ReleaseCapture Lib "user32" () As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Now in your form mousedown event for VB use:

Private sub form1_mousedown(ByVal Button As Integer,Byval Shift as integer,ByVal X as single,ByVal Y as Single)

CALL ReleaseCapture

end sub

For VBA we have to obtain the hwnd of our userform to supply as the first parameter to SendMessage. Do this with the code below.

hwnd = IIF(val(application.version) < 9,"ThunderXframe","ThunderDFrame"), Userform1.caption)

Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close