nesco писал(а):
А я тебе про что тут талдонил страницу назадДа работала у меня моя схема. Файл hiTreeViewTrain.pas менялся с того времени сколько раз одному Dilma известно.
nesco писал(а):
А то -- версия не та, стянуть забылЭто исключено: Dilma правил я сразу тестил.

//---------------------------- DRAG DROP ---------------------------------------
procedure THITreeViewTrain._OnBeginDrag( Sender: PControl; Item: THandle );
begin
FDrag := true;
Control.Cursor := crUpArrow;
Control.TVSelected := Item;
FLastSelect := 0;
end;
procedure THITreeViewTrain._onMouseMove;
var c,where:cardinal;
dt:TData;
begin
inherited;
c := Control.TVItemAtPos(Mouse.X, Mouse.Y, where);
if not FDrag or(FLastSelect = c) or (c = 0) then exit;
Control.TVItemDropHighlighted[FLastSelect] := false;
dt := PData(Control.TVItemData[c])^;
_ReadData(dt, _data_DropAccept);
if ToInteger(dt) <> 0 then
begin
Control.TVItemDropHighlighted[c] := true;
Control.Cursor := crUpArrow;
FLastSelect := c;
end
else
begin
Control.Cursor := 39;
FLastSelect := 0;
end;
end;
procedure THITreeViewTrain._onMouseUp;
var c,where,sel:cardinal;
d,fd
Data;
pd:TData;
i:integer;
begin
inherited;
if not FDrag then exit;
c := FLastSelect;
if c <> 0 then
begin
sel := Control.TVSelected;
d := Control.TVItemData[sel];
pd := PData(Control.TVItemData[c])^;
getItem(pd, _prop_IDIndex);
fd := d;
i := 0;
while fd <> nil do
begin
if i = _prop_ParentIDIndex then
begin
fd.data_type := pd.data_type;
fd.idata := pd.idata;
fd.sdata := pd.sdata;
fd.rdata := pd.rdata;
break;
end;
inc(i);
fd := fd.ldata;
end;
AddNode(d^);
_hi_onEvent_(_event_onDrop, d^);
FClear := true;
Control.TVDelete(sel);
FClear := false;
end;
Control.TVItemDropHighlighted[FLastSelect] := false;
FLastSelect := 0;
FDrag := false;
Control.Cursor := crDefault;
end;
end.
procedure THITreeViewTrain._OnBeginDrag( Sender: PControl; Item: THandle );
begin
FDrag := true;
Control.Cursor := crUpArrow;
Control.TVSelected := Item;
FLastSelect := 0;
end;
procedure THITreeViewTrain._onMouseMove;
var c,where:cardinal;
dt:TData;
begin
inherited;
c := Control.TVItemAtPos(Mouse.X, Mouse.Y, where);
if not FDrag or(FLastSelect = c) or (c = 0) then exit;
Control.TVItemDropHighlighted[FLastSelect] := false;
dt := PData(Control.TVItemData[c])^;
_ReadData(dt, _data_DropAccept);
if ToInteger(dt) <> 0 then
begin
Control.TVItemDropHighlighted[c] := true;
Control.Cursor := crUpArrow;
FLastSelect := c;
end
else
begin
Control.Cursor := 39;
FLastSelect := 0;
end;
end;
procedure THITreeViewTrain._onMouseUp;
var c,where,sel:cardinal;
d,fd

pd:TData;
i:integer;
begin
inherited;
if not FDrag then exit;
c := FLastSelect;
if c <> 0 then
begin
sel := Control.TVSelected;
d := Control.TVItemData[sel];
pd := PData(Control.TVItemData[c])^;
getItem(pd, _prop_IDIndex);
fd := d;
i := 0;
while fd <> nil do
begin
if i = _prop_ParentIDIndex then
begin
fd.data_type := pd.data_type;
fd.idata := pd.idata;
fd.sdata := pd.sdata;
fd.rdata := pd.rdata;
break;
end;
inc(i);
fd := fd.ldata;
end;
AddNode(d^);
_hi_onEvent_(_event_onDrop, d^);
FClear := true;
Control.TVDelete(sel);
FClear := false;
end;
Control.TVItemDropHighlighted[FLastSelect] := false;
FLastSelect := 0;
FDrag := false;
Control.Cursor := crDefault;
end;
end.

//---------------------------- DRAG DROP ---------------------------------------
procedure THITreeViewTrain._OnBeginDrag( Sender: PControl; Item: THandle );
begin
FDrag := true;
Control.Cursor := crHandPoint;
Control.TVSelected := Item;
FLastSelect := 0;
end;
procedure THITreeViewTrain._onMouseMove;
var c,where:cardinal;
dt:TData;
begin
inherited;
c := Control.TVItemAtPos(Mouse.X, Mouse.Y, where);
if not FDrag or(FLastSelect = c) or (c = 0) then exit;
Control.TVItemDropHighlighted[FLastSelect] := false;
dt := PData(Control.TVItemData[c])^;
_ReadData(dt, _data_DropAccept);
if ToInteger(dt) <> 0 then
begin
Control.TVItemDropHighlighted[c] := true;
Control.Cursor := crHandPoint;
FLastSelect := c;
end
else
begin
Control.Cursor := crNo;
FLastSelect := 0;
end;
end;
procedure THITreeViewTrain._onMouseUp;
var c,where,sel,lastNode:cardinal;
d,fd
Data;
pd:TData;
i:integer;
procedure moveNodes(fromNode, toNode:cardinal);
var n:cardinal;
p:cardinal;
begin
p := Control.TVItemChild[fromNode];
while p > 0 do
begin
n := Control.TVInsert(toNode, 0, Control.TVItemText[p]);
Control.TVItemData[n] := Control.TVItemData[p];
Control.TVItemData[p] := 0;
Control.TVItemImage[n] := Control.TVItemImage[p];
Control.TVItemSelImg[n] := Control.TVItemImage[p];
moveNodes(p, n);
p := Control.TVItemNext[p];
end;
end;
function isNodeCross(fromNode, toNode:cardinal):boolean;
var p:cardinal;
begin
Result := True;
if fromNode = toNode then exit;
p := Control.TVItemChild[fromNode];
while p > 0 do
begin
if isNodeCross(p, toNode) then exit;
p := Control.TVItemNext[p];
end;
Result := false;
end;
begin
inherited;
if not FDrag then exit;
c := FLastSelect;
if(c <> 0)and not isNodeCross(Control.TVSelected, c) then
begin
sel := Control.TVSelected;
d := Control.TVItemData[sel];
pd := PData(Control.TVItemData[c])^;
getItem(pd, _prop_IDIndex);
fd := d;
i := 0;
while fd <> nil do
begin
if i = _prop_ParentIDIndex then
begin
fd.data_type := pd.data_type;
fd.idata := pd.idata;
fd.sdata := pd.sdata;
fd.rdata := pd.rdata;
break;
end;
inc(i);
fd := fd.ldata;
end;
AddNodeAt(c, d^, @lastNode);
moveNodes(sel, lastNode);
_hi_onEvent_(_event_onDrop, d^);
FClear := true;
Control.TVDelete(sel);
FClear := false;
end;
Control.TVItemDropHighlighted[FLastSelect] := false;
FLastSelect := 0;
FDrag := false;
Control.Cursor := crDefault;
end;
end.
procedure THITreeViewTrain._OnBeginDrag( Sender: PControl; Item: THandle );
begin
FDrag := true;
Control.Cursor := crHandPoint;
Control.TVSelected := Item;
FLastSelect := 0;
end;
procedure THITreeViewTrain._onMouseMove;
var c,where:cardinal;
dt:TData;
begin
inherited;
c := Control.TVItemAtPos(Mouse.X, Mouse.Y, where);
if not FDrag or(FLastSelect = c) or (c = 0) then exit;
Control.TVItemDropHighlighted[FLastSelect] := false;
dt := PData(Control.TVItemData[c])^;
_ReadData(dt, _data_DropAccept);
if ToInteger(dt) <> 0 then
begin
Control.TVItemDropHighlighted[c] := true;
Control.Cursor := crHandPoint;
FLastSelect := c;
end
else
begin
Control.Cursor := crNo;
FLastSelect := 0;
end;
end;
procedure THITreeViewTrain._onMouseUp;
var c,where,sel,lastNode:cardinal;
d,fd

pd:TData;
i:integer;
procedure moveNodes(fromNode, toNode:cardinal);
var n:cardinal;
p:cardinal;
begin
p := Control.TVItemChild[fromNode];
while p > 0 do
begin
n := Control.TVInsert(toNode, 0, Control.TVItemText[p]);
Control.TVItemData[n] := Control.TVItemData[p];
Control.TVItemData[p] := 0;
Control.TVItemImage[n] := Control.TVItemImage[p];
Control.TVItemSelImg[n] := Control.TVItemImage[p];
moveNodes(p, n);
p := Control.TVItemNext[p];
end;
end;
function isNodeCross(fromNode, toNode:cardinal):boolean;
var p:cardinal;
begin
Result := True;
if fromNode = toNode then exit;
p := Control.TVItemChild[fromNode];
while p > 0 do
begin
if isNodeCross(p, toNode) then exit;
p := Control.TVItemNext[p];
end;
Result := false;
end;
begin
inherited;
if not FDrag then exit;
c := FLastSelect;
if(c <> 0)and not isNodeCross(Control.TVSelected, c) then
begin
sel := Control.TVSelected;
d := Control.TVItemData[sel];
pd := PData(Control.TVItemData[c])^;
getItem(pd, _prop_IDIndex);
fd := d;
i := 0;
while fd <> nil do
begin
if i = _prop_ParentIDIndex then
begin
fd.data_type := pd.data_type;
fd.idata := pd.idata;
fd.sdata := pd.sdata;
fd.rdata := pd.rdata;
break;
end;
inc(i);
fd := fd.ldata;
end;
AddNodeAt(c, d^, @lastNode);
moveNodes(sel, lastNode);
_hi_onEvent_(_event_onDrop, d^);
FClear := true;
Control.TVDelete(sel);
FClear := false;
end;
Control.TVItemDropHighlighted[FLastSelect] := false;
FLastSelect := 0;
FDrag := false;
Control.Cursor := crDefault;
end;
end.