trichview.support
Re: Drag and Drop file into the table... |
Author |
Message |
CKC |
Posted: 12/06/2002 20:52:22 Dear Sergey, here is my solution to the problem. With my little function "IsCursorInsideTable" I can get the table, the tablename and the row and column, no matter what is inside the cell of the table. Best wishes ckc procedure TFrameOrderText.RVDragDrop(Sender, Source: TObject; X,Y: Integer); var Row,Col : Integer; ItemName : string; table : TRVTableItemInfo; begin MoveCaretTo(X,Y); if IsCursorInsideTable(X,Y,ItemName,table,Row,Col) then begin table.cells[Row,Col].clear; table.cells[Row,Col].AddNL('test'+IntToStr(sn),0,0); inc(sn); rv.format; end; end; function TFrameOrderText.IsCursorInsideTable(X,Y:integer; var ItemName : string; var table: TRVTableItemInfo; var Row,Col : integer) : boolean; var ItemNo,ItemStyle,ACX,ACY :integer; PHandle : THandle; PtInPoly : bool; begin result:=false; ItemNo:=0; while ItemNo<rv.ItemCount do begin ItemStyle:=rv.GetItemStyle(ItemNo); if ItemStyle=rvsTable then begin table := TRVTableItemInfo(rv.GetItem(ItemNo)); if rv.GetItemClientCoords(ItemNo,ACX,ACY) then begin PHandle := CreateRectRgn(ACX,ACY,ACX+table.Width,ACY+table.Height); PtInPoly := PtInRegion(PHandle,X,Y); if PtInPoly then if table.GetCellAt(X-ACX,Y-ACY,Row,Col) then begin ItemName:= rv.GetItemText(ItemNo); result := true; ItemNo := rv.ItemCount; end; DeleteObject(PHandle); // remove handle end; // if rv.GetItemClientCoords( end; // if ItemStyle=rvsTable inc(ItemNo); end; // while ItemNo<rv.ItemCount do end; "Sergey Tkachenko" <svt@trichview.com> wrote: >When you finishes dragging, the caret is in the destination table. >You can get it with GetCurrentItemEx method. > > >> I use TRichViewEdit as an order form for a pharmacy interface. I drag the >text >> from a TListBox. >> Inside TRichViewEdit each row of a table represents a certain drug (only >one >> drug per row allowed). >> When the DragDrop event occurs I need to know which table and which cell >> contains the drug. > > > |
Powered by ABC Amber Outlook Express Converter