1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| procedure TForm1.StringGrid1MouseMove(Sender: TObject;Shift: TShiftState; X, Y: Integer);
Var
ACol, ARow: Longint;
ARect: TRect;
ScreenPoint : TPoint;
ClientPoint : TPoint;
GridPoint : TPoint;
begin
StringGrid1.MouseToCell(X, Y, ACol, ARow);
GetCursorPos(ScreenPoint);
ARect:=StringGrid1.CellRect(ACol,ARow);
ClientPoint := Panel5.ScreenToClient(ScreenPoint);
GridPoint := StringGrid1.ScreenToClient(ScreenPoint);
// Pour suivre la position et comprendre le truc
Label7.Caption:=Format('Largeur %d - Left %d - Pt.X %d' ,[aRect.width, aRect.Left, ClientPoint.Y]);
Label7.Update;
Label8.Caption:=Format('Top %d - Bottom %d - Pt.Y %d - Panel.top %d' ,[aRect.Top, aRect.Bottom, ScreenPoint.Y, Panel_Liste1.Top]);
Label8.Update;
if (ARow>0)
then begin
if (ACol=0)
then begin
if (ClientPoint.X>=ARect.Left+ARect.width + StringGrid1.GridLineWidth - Image_Liste1.Width)
and (ClientPoint.X<=ARect.Left+ARect.width)
then begin
Panel_Liste1.Visible:=true;
Panel_Liste1.BringToFront;
Panel_Liste1.Width:=Image_Liste1.Width;
Panel_Liste1.Left:=aRect.Left + aRect.width + StringGrid1.GridLineWidth - Image_Liste1.Width;
Panel_Liste1.Top:= ClientPoint.Y; //(ScreenPoint.Y div (StringGrid1.DefaultRowHeight + StringGrid1.GridLineWidth))*(StringGrid1.DefaultRowHeight + StringGrid1.GridLineWidth)+1;
Panel_Liste1.Height:=StringGrid1.DefaultRowHeight;
StringGrid1.Invalidate;
end
else begin
Panel_Liste1.Visible:=False;
StringGrid1.Invalidate;
end;
end
else begin
Panel_Liste1.Visible:=False;
StringGrid1.Invalidate;
end;
end;
end; |
Partager