Form1 is used as the Tool Box to hold the chess pieces
Form2 is used as the Chess board
Form1 has these objects (basically pictureboxes with images of chess pieces in them).
I need to mouse down and move a chess piece from Form1, crossing over the gap between the two Forms, over to Form2 and then position it on a square on Form2.
The chess piece image must show from start to finish and it must show on top of anything else including the screen and the Form borders and any controls which happen to be in it's path
Years ago I did exactly this and I think I used BitBlt (and maybe not) but I don't remember the details of how I did it and the original chess game code is lost.
I have some code that I have been playing around with that makes a mouse icon out of the chess pieces but this code only allows the chess piece to be moved within a single Form only
Here is the code
Form2 is used as the Chess board
Form1 has these objects (basically pictureboxes with images of chess pieces in them).
I need to mouse down and move a chess piece from Form1, crossing over the gap between the two Forms, over to Form2 and then position it on a square on Form2.
The chess piece image must show from start to finish and it must show on top of anything else including the screen and the Form borders and any controls which happen to be in it's path
Years ago I did exactly this and I think I used BitBlt (and maybe not) but I don't remember the details of how I did it and the original chess game code is lost.
I have some code that I have been playing around with that makes a mouse icon out of the chess pieces but this code only allows the chess piece to be moved within a single Form only
Here is the code
Code:
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Picture1.MousePointer = vbCustom ' Set to custom icon.
If Picture1Started Then
rc% = BitBlt%(Picture1.hdc, previous_X - 10, previous_Y - 10, picSave.ScaleWidth, picSave.ScaleHeight, picSave.hdc, 0, 0, SRCCOPY)
End If
rc% = BitBlt%(picSave.hdc, 0, 0, picSave.ScaleWidth, picSave.ScaleHeight, Picture1.hdc, x - 10, y - 10, SRCCOPY)
rc% = BitBlt%(Picture1.hdc, x - 10, y - 10, picTargetMask.ScaleWidth, picTargetMask.ScaleHeight, picTargetMask.hdc, 0, 0, SRCAND)
rc% = BitBlt%(Picture1.hdc, x - 10, y - 10, picTarget.ScaleWidth, picTarget.ScaleHeight, picTarget.hdc, 0, 0, SRCPAINT)
previous_X = x
previous_Y = y
Picture1Started = True
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Picture1.MousePointer = vbCustom ' Set to custom icon.
If Picture1Started Then
rc% = BitBlt%(Picture1.hdc, previous_X - 10, previous_Y - 10, picSave.ScaleWidth, picSave.ScaleHeight, picSave.hdc, 0, 0, SRCCOPY)
End If
rc% = BitBlt%(picSave.hdc, 0, 0, picSave.ScaleWidth, picSave.ScaleHeight, Picture1.hdc, x - 10, y - 10, SRCCOPY)
rc% = BitBlt%(Picture1.hdc, x - 10, y - 10, picTargetMask.ScaleWidth, picTargetMask.ScaleHeight, picTargetMask.hdc, 0, 0, SRCAND)
rc% = BitBlt%(Picture1.hdc, x - 10, y - 10, picTarget.ScaleWidth, picTarget.ScaleHeight, picTarget.hdc, 0, 0, SRCPAINT)
previous_X = x
previous_Y = y
Picture1Started = True
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
End Sub