Link to home
Start Free TrialLog in
Avatar of keimpe
keimpe

asked on

How to draw a rectangle on a form using the mouse?

Dear everyone,

I want to let my users create clickable maps in Access. I want to accomplish this by presenting them with a form with an image on it and then letting them draw a rectangle by dragging the mouse across a selection of the image. After they release the mouse, I need to pick up the Top, Left, Right and Bottom values of the rectangle.

Can this be done?

I played around with this Lebans tool a little: http://www.lebans.com/imageclass.htm so I think it can be done, but I'm not clever enough to change his code. I hope you are.

Thanks,
Keimpe

ASKER CERTIFIED SOLUTION
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keimpe
keimpe

ASKER

That's brilliant Harfang, thanks!

One last thing though: I would like to see the actual drawing happening. With this code I don't see the rectangle until it's done. Do you know a way?
Avatar of keimpe

ASKER

Got it myself!

Insert a "Me.Repaint" just underneath the "End With" in "imaSelect_MouseMove"
Hello keimpe

I didn't need that on Access 2k. I believe there is a new form property for later versions, something like "auto redraw", that might play a role here.
Anyway, glad it worked! Good luck with your project!

(°v°)