Hi
There are two commands which reveal the location of the mouse cursor within the DBPRO window.
MouseX() & MouseY()
So you can check which grid tile overlaps the mouse using an expression:
If MouseX() => Grid(c).Left And MouseY() => Grid(c).Top And MouseX() < Grid(c).Right And MouseY() < Grid(c).Bottom Then TileUnderMouse = c
There are other ways to solve the problem but this is the easiest way I can think of.
c = 1
For x = 1 to 30
For y =1 to 30
If MouseX() => Grid(c).Left And MouseY() => Grid(c).Top And MouseX() < Grid(c).Right And MouseY() < Grid(c).Bottom Then TileUnderMouse = c
Inc c
Next y
Next x
You could also calculate the tile mathematically using the following:
x = Floor( MouseX() / woftile ) + 1
y = Floor( MouseY() / hoftile ) + 1
TileUnderMouse = x + ( ( y - 1 ) * 30 )
The calculation process will run faster but is more difficult to read. I've assumed your array index starts at 1. If not, deduct 1 from TileUnderMouse in the last line of the calculation example.
Edit: Note that if the mouse position is out of tile range, the wrong tile will be returned; so in both examples, you should check that the mouse is within the grid; if it is not then set the TileUnderMouse as zero, to indicate that there is no tile under the mouse.