Q for Steve Lebans: Query by picturebox?

B

BrainlordMesomorph

Hi Steve,

Using your PictureBox control to make a picture of a db, literally.

I've added 2 fields for xy coords in a couple of tables, and I have a
cute little sub that draws a rectangle for each record of one table
and a little circle for each record in the other. Then it draws lines
connecting related records. Its really cool.

Thanks again for the control.

Now that I have that picture, I want to be able to click and have it
open a form with the right record displayed.

The mousedown event gives me the XY of where I click, and I could
probebly figure out a query that would give me all the records (really
one or less)where (X is > X1 and < X2) and (Y is >Y1 and < Y2). or
something like that

So clicking on the circles and squares aren't really the problem. But
before I start with that, My question is what about the connecting
lines?

I mean: How can tell if the user is clicking within 5 pixels or so
each side of a line between x1,y1 and x2,y2?

And what do you think of my using the MouseDown event to return the XY
of the click, and then a query to figure out which circle square or
line the user clicked on.

Just looking for some advice from the Master.
aha tia
blm
 
M

Michel Walsh

Hi,


I don't use "Steve"'s control, but I assume you can use the API
functions PtInRect and PtInRegion. The second function can take any "region"
while the first one is limited to rectangle with sides parallel to the
window. AllApi (www.allapi.net) supply an example for the two mentioned
subroutine. Take a look at CreatePolydonRgn and CreatePolyPolygonRgn for
complex regions.


If your objects are not all "rectangular", generally the process is to
assign a rectangular box delimiting each object. Then, the db find the
objects having the point you click on inside their delimiting box (which is
fast on indexed fields, since it is a matter to use xClick BETWEEN
FieldXmin AND FieldXmax, same for Y. Having found a limited number of
objects, you can then make further check on those: a star, a circle, a
triangle, ... would have a lot of points in their bounding rectangle that is
not their, specifically... but having far less objects to deal with, the
extra computation required (using PtInRegion, or other), should be less
critical.



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top