Hi Roger and welcome to ExcelForum,
Very nice job on the Chess game.
I think the solution to your problem is by being able to interpret Mouse_Move events in clsBoardField. I added Mouse_Up and Mouse_Move events to see what happens. I didn't have time to figure out the coordinate system, but it seems like all the information is there.
clsBoardField excerpts:
When I depress the mouse button (value = 1) and move from square 8 to square 24 then release the mouse button (value = 0) I get the following Scenario:
a. Mouse Down and Mouse Up in Square 8
b. Mouse Down in Square 8
c. Drag to Square 24
d. Mouse Down and Mouse Up in Square 24
Conclusion:
a. Mouse_Up event always is paired with the Mouse_Down event. Mouse_Down in Square8 and Mouse_Up in Square24 always generates a Mouse_Up in Square 8 event (not very useful).
b. Mouse_Down followed by Mouse_move with Button value NON-ZERO is Useful. The Mouse_Down indicates the square where the 'Drag and Drop' started.
c. When Mouse_Move Button changes from 1 to 0 (followed by Mouse_Up for original square) indicates the end of the 'Drag and Drop'. If you can convert the XY coordinates into a 'Square Number', you should be all set to interpret the request as a move request.
On further investigation, I see that the top/left of each square is 0,0. That makes what I did above useless. However, if you can generate an event for the entire board, you can then resolve the Mouse Events into the proper squares.
I hope this helps.
Lewis
Bookmarks