Move Controls at Runtime with Very Little Code

Forms and Controls
John Conwell

Version Compatibility: Visual Basic 6

More information:
Here is a very light weight way to move your controls around at runtime. Just put the two APIs and the two constants at the top of the code section of your form (or to a module to make them global...just remember to make them public). Then add two command buttons and two text boxes to your form. Paste the four mouse down events into the code section of your form. Run the app and click/drag your controls around. I've used this in apps where the users want the ability to rearange the form. Then on the form unload event, I looped through each control on the form and stored off their top and left positions in the registry. Next time the app loads, look up the positions and move the controls to where they were before app was closed.

Instructions: Copy the declarations and code below and paste directly into your VB project.