Here's what I am doing
I have a Form with a Picture1 on it. The picture in Picture1 is a chess board pattern
I am using Forms to represent the chess pieces.
So I have Form1 which is the main Form (the chess board) of the app and I have an array of 32 other Forms (Form2). Each one of these other Forms is a chess piece.
Example 1:
Form2(1) = Black Rook
Form2(2) = Black Knight
'
'
Form2(32) = White Rook
When the app first starts up the 32 Forms that represent the chess pieces are positioned on top of Form1.Picture1 in their respective squares.
At this point (start up) each of the pieces are set to the child of Picture1
Example 2:
SetParent Form2(index).hwnd, Picture1.hwnd
etc
Now when I move Form1 around the 32 other Forms move with it (just as though they were a drawing)
When I mouse down on a chess piece (Form2(index)) the Form is made a child of the desktop
Example 3:
In Form2(index) Form_MouseDown(.......)
SetParent Me.hwnd, 0
Now I can move this piece anywhere I want to. When the piece is moved to an open square on Form1.Picture1 the piece is once again made a child of Picture1
Here's where the problem comes in. If I again mouse down on the same piece (remember, it will become the child of the desktop - Example 3) it moves suddenly to some position way off to the left side of the desktop but it should stay on the square where it was when I moused down on it a second time. I think the problem here has to do with changing it's owner back to the desktop.
What I need is how do I keep the piece from wandering off to that extreme position and keep it positioned on the square where it was. Does this have something to do with ScreenToClient or ClientToScreen APIs and if so how to use them if that be the case
I have a Form with a Picture1 on it. The picture in Picture1 is a chess board pattern
I am using Forms to represent the chess pieces.
So I have Form1 which is the main Form (the chess board) of the app and I have an array of 32 other Forms (Form2). Each one of these other Forms is a chess piece.
Example 1:
Form2(1) = Black Rook
Form2(2) = Black Knight
'
'
Form2(32) = White Rook
When the app first starts up the 32 Forms that represent the chess pieces are positioned on top of Form1.Picture1 in their respective squares.
At this point (start up) each of the pieces are set to the child of Picture1
Example 2:
SetParent Form2(index).hwnd, Picture1.hwnd
etc
Now when I move Form1 around the 32 other Forms move with it (just as though they were a drawing)
When I mouse down on a chess piece (Form2(index)) the Form is made a child of the desktop
Example 3:
In Form2(index) Form_MouseDown(.......)
SetParent Me.hwnd, 0
Now I can move this piece anywhere I want to. When the piece is moved to an open square on Form1.Picture1 the piece is once again made a child of Picture1
Here's where the problem comes in. If I again mouse down on the same piece (remember, it will become the child of the desktop - Example 3) it moves suddenly to some position way off to the left side of the desktop but it should stay on the square where it was when I moused down on it a second time. I think the problem here has to do with changing it's owner back to the desktop.
What I need is how do I keep the piece from wandering off to that extreme position and keep it positioned on the square where it was. Does this have something to do with ScreenToClient or ClientToScreen APIs and if so how to use them if that be the case