Drag & Drop TDragObject
Posted on 2001-08-24
Hi, just a little background! I have 3 types of controls
Tjob: an ancestor of Tstatictext
Tresource: an ancestor of Tpanel
TAdvStringGrid: an ancestor of tstringgrid (From RX suite)
Multiple instances of Tjobs can sit on multiple instances of TPanel. TAdvStringGrid can also hold Tjobs in its objects array, and displays corresponding info on each row for each associated Tjob it has. Basically I want to be able to drag Tjobs between the Tresource panels and the TAdvStringGrid. Dragging a job to the grid isn't a problem, but I can't work out how I can drag the Tjob item corresponding to the row selection from the grid on to a TResource panel.
TheTjob item I want to drag is given by:
AdvStringGrid.objects[0,AdvStringGrid.Row] as TJob;
The Tresource drag & drop handlers require a Tjob object, ie:
procedure TResource.ResourceDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
If Source is TJob then
Accept:=IsCanAcceptJob(Source as TJob)
(& similar for DragDrop)
So this is fine when dragging a Tjob on a Tresource, but when dragging from the grid, the Source becomes TadvStringGrid. Basically need to change it so that
Source is a specific TJob within the grid.
So do I need to create a TDragObject to do this and if so how should/can I pass the selected Tjob information within the TDragObject? Hope u can help, and sorry this is a little long winded, although I'm sure you're used to my protracted explanations by now!!! Many thanks, P.