K
Hallo,
wahrscheinlich musst du die Mauskoordinaten auf dem Panel noch rausrechnen.
// in *.h
private:
bool dragndrop;
int xpos;
int ypos;
//--------------------
in *.cpp
void __fastcall TForm1::Panel1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
dragndrop = ! dragndrop;
xpos = X; // Mauskoordinaten auf dem Panel, speichern
ypos = Y;
}
// in WndProc:
.
::ScreenToClient(Form1->Handle, &P);
if (dragndrop) {
Panel1->Left = P.x - xpos;
Panel1->Top = P.y - ypos;
}
.
.
Beim Klick aufs Panel wird der bool gesetzt, die X- und Y- Pos wird gespeichert.
Wird die Maus nun bewegt, geht das Panel mit. Beim nächsten Mausklick wird das Panel abgelegt. Pixelgenau
Probiers mal so.