home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sibdemo3.zip
/
SAMPLES.DAT
/
SAMPLES
/
DRAGDROP
/
INTERN
/
DRAGU1.PAS
next >
Wrap
Pascal/Delphi Source File
|
1997-07-28
|
3KB
|
76 lines
Unit DragU1;
Interface
Uses
Classes, Forms, Graphics, StdCtrls, Buttons;
Type
TDragForm = Class (TForm)
Label1: TLabel;
Label2: TLabel;
Container1: TListBox;
Container2: TListBox;
Label3: TLabel;
Procedure ContainerOnEndDrag (Sender: TObject; Target: TObject;
X: LongInt; Y: LongInt);
Procedure ContainerOnDragDrop (Sender: TObject; Source: TObject;
X: LongInt; Y: LongInt);
Procedure ContainerOnDragOver (Sender: TObject; Source: TObject; X: LongInt;
Y: LongInt; State: TDragState;
Var Accept: Boolean);
Procedure ContainerOnCanDrag (Sender: TObject; X: LongInt; Y: LongInt;
Var Accept: Boolean);
Private
{Insert private declarations here}
Public
{Insert public declarations here}
End;
Var
DragForm: TDragForm;
Implementation
Procedure TDragForm.ContainerOnEndDrag (Sender: TObject; Target: TObject;
X: LongInt; Y: LongInt);
Var t:LongInt;
Begin
//remove items from source container
If ((Target=Container1)Or(Target=Container2)) And (Sender<>Target) Then
For t:=TListBox(Sender).Items.Count-1 DownTo 0 Do
If TListBox(Sender).Selected[t] Then TListBox(Sender).Items.Delete(t);
End;
Procedure TDragForm.ContainerOnDragDrop (Sender: TObject; Source: TObject;
X: LongInt; Y: LongInt);
Var t:LongInt;
Begin
If ((Source=Container1)Or(Source=Container2)) Then
If ((Sender=Container1)Or(Sender=Container2)) Then
If Sender<>Source Then
Begin
//insert items into target container
For t:=0 To TListBox(Source).Items.Count-1 Do
If TListBox(Source).Selected[t] Then
TListBox(Sender).Items.Add(TListBox(Source).Items[t]);
End;
End;
Procedure TDragForm.ContainerOnDragOver (Sender: TObject; Source: TObject;
X: LongInt; Y: LongInt;
State: TDragState; Var Accept: Boolean);
Begin
Accept:=((Source=Container1)Or(Source=Container2)) And (Sender<>Source);
End;
Procedure TDragForm.ContainerOnCanDrag (Sender: TObject; X: LongInt; Y: LongInt;
Var Accept: Boolean);
Begin
Accept:=TListBox(Sender).SelCount>0;
End;
Initialization
RegisterClasses ([TDragForm, TLabel, TListBox]);
End.