Grid - Pre Sale Questions
Dropping file(s) on grid
Thread Starter: Alfred Started: 5/5/2008 8:31 PM UTC
Replies: 2
Dropping file(s) on grid
I am dropping files (one or more) on to a row in the grid and I need to know which row (or column) the files were dropped on. Here is as far as I got and I do not seem to be able to get the row number - just the active row:

procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
var
  DropHandle : HDROP;
  GlobalPoint, LocalPoint: TPoint;
  n1, DroppedFileCount, FileNameLength: Integer;
  DropPoint: TPoint;
  FileName: String;
begin
//  StringList1.Add('Msg.Message = $' + IntToHex(Msg.message, 4));

  if Msg.Message = WM_DROPFILES then
    begin
    Handled := True;
    DropHandle := Msg.wParam;
    DroppedFileCount := DragQueryFile(DropHandle, $FFFFFFFF, nil, 0);
    DragQueryPoint(DropHandle, DropPoint);
    RowDroppedOn := ProfGrid1.Row;

    if ((RowDroppedOn > 0) and (RowDroppedOn < (ProfGrid1.RowCount))) then
      begin
      for n1 := 0 to (DroppedFileCount - 1) do
        begin
        FileNameLength := DragQueryFile(DropHandle, n1, nil, 0);
        SetLength(FileName, FileNameLength);
        DragQueryFile(DropHandle, n1, PChar(FileName), FileNameLength + 1);

        ShowMessage('RowDroppedOn=' + IntToStr(RowDroppedOn));
        end;  //  n1 := 0 to (DroppedFileCount - 1)
      end;  //  ((row > 0) and (row < StringGrid1.RowCount))

    DragFinish(DropHandle);
    end;  //  Msg.Message = WM_DROPFILES

end;


Re: Dropping file(s) on grid
Hello Alfred:

   P := ProfGrid1.ScreenToClient(ClientToScreen(DropPoint));
   ProfGrid1.MouseToCell(P.X, P.Y, ColumnDroppedOn, RowDroppedOn);


-Nicholas
Re: Dropping file(s) on grid
Thank you.