Registriert seit: 19. Jun 2006
Ort: Vreden
67 Beiträge
Delphi 11 Alexandria
|
Re: Listbox Einträge verschieben
5. Mär 2007, 22:18
Das Flickern ist auch beim code von bitsetter da
nach ein wenig suche im forum http://www.delphipraxis.net/internal...light=flickern
habe ich es doch noch wegbekommen
Delphi-Quellcode:
var
Form1: TForm1;
Listindex : integer;
implementation
{$R *.dfm}
procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
var
n,offset,maxoffset,minoffset : integer;
SourceSel : array of boolean;
begin
if (Sender = Source) and (Sender is TListbox) and ((Source as Tlistbox).ItemIndex <> -1) then
begin
with Source as TListbox do
begin
//Selected Sichern und max offset feststellen
SetLength(SourceSel,Count);
for n := 0 to Count -1 do
begin
SourceSel[n] := Selected[n];
if SourceSel[n] then maxoffset := n - Count;
end;
//Min Offset feststellen
for n := Count -1 downto 0 do
if SourceSel[n] then minoffset := n ;
//Um wieviele Felder verschieben
offset:= Listindex - ItemAtPos(point(x,y),true);
//Verschieben begrenzen
if (ItemAtPos(point(x,y),true) = -1) then exit;
if (offset <= maxoffset) then exit;
if (offset > minoffset) then exit;
if offset = 0 then exit;
//Zeichnen ausschalten
Self.Perform(wm_SetRedraw, 0, 0);
//Verschieben
if offset > 0 then
begin
for n := 0 to Count -1 do
if SourceSel[n] then Items.Move(n,n - offset);
end
else if offset < 0 then
begin
for n := Count -1 downto 0 do
if SourceSel[n] then Items.Move(n,n - offset);
end;
//Selected setzen
for n := 0 to Count -1 do
if (n + offset) >= Count then Selected[n] := false else
Selected[n] := SourceSel[n + offset];
//Itemindex neu setzen
Listindex := Listindex - offset;
itemindex := Listindex;
//Zeichen einschalten
Self.Perform(wm_SetRedraw, 1, 0);
repaint;
end; //with listbox
Accept:= true
end
else Accept:= false;
end;
procedure TForm1.ListBox2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
with Sender as TListBox do
Listindex := ItemAtPos(point(x,y),true);
end;
Thomas Levering
|
|
Zitat
|