Looking for Visual Basic help

I’m trying to build a Project for a continuing ed class. This project has two forms.
Ultimately, as far as this question goes, I want to be able to have the second form (which is called from a command button click on the first form) move when I drag the first form anywhere on the screen.

Maybe I’m just using the DragDrop method wrong, but I can’t get it to move.

Could anyone offer a pointer in the right direction?

Thanks in advance,

-j

I’d recommend using the mousemove event.

I think perhaps the mouseup event on the form (shame they don’t have a move event). Check the form postion on mouseup, if it’s different from the previous position, access the other form and move it, too. I’d run the same code on the “lost focus” & “resize” events, too.

-B

In addition to the methods above, there are several other ways of accomplishing this feat, each with its own pros and cons.

If you are just learning VB, I would recommend this method:
You can add a timer to your form and save the forms coords to variables. Then each time the timer fires, check the coords to see if they have changed. If they have, modify second form’s coords accordingly. This is very easy, but might look a little kludgy in action.

If you are an experienced developer, I would highly recommend the following method, as it uses the API and eliminates some of the flickering, etc., that you’ll get with a pure VB method:

Hook into (intercept) windows messages and look for WM_MOVE to fire. When it does, you can reposition your subform at that time. It’s very clean and looks nice, but might be a bit complex to design if you’re not familiar with the API.

If you need more info to get you started, let us know and I’m sure myself or someone else can give you a hand. If this is homework, I’m not going to do it for you, but will gladly give you pointers and ideas.

In addition to the methods above, there are several other ways of accomplishing this feat, each with its own pros and cons.

If you are just learning VB, I would recommend this method:
You can add a timer to your form and save the forms coords to variables. Then each time the timer fires, check the coords to see if they have changed. If they have, modify second form’s coords accordingly. This is very easy, but might look a little kludgy in action.

If you are an experienced developer, I would highly recommend the following method, as it uses the API and eliminates some of the flickering, etc., that you’ll get with a pure VB method:

Hook into (intercept) windows messages and look for WM_MOVE to fire. When it does, you can reposition your subform at that time. It’s very clean and looks nice, but might be a bit complex to design if you’re not familiar with the API.

If you need more info to get you started, let us know and I’m sure myself or someone else can give you a hand. If this is homework, I’m not going to do it for you, but will gladly give you pointers and ideas.

I would be inclined to think of a way to do this program that didn’t require two windows to move in unison. That kind of wacky, unexpected non-standard behavior annoys me as a user, so I wouldn’t do it as a programmer. So unless it’s absolutely necessary for it to work that way, consider trying a different approach.

Thanks everyone, I think I got it figured out.

I know it’s goofy, Manduck, but it was more a “proof of understanding” project than a best-practice application.
I really appreciate the advice, all. :slight_smile:

-j