I have a problem using TChartListBox with Drag & Drop. I use the DropMaster component from www.raize.com for Drag & Drop.
My ListBox has Multiselect and ExtendedSelect enabled. So the user can select any series he wants. Lets say we have 3 series and the user selects 2 of them. This works fine.
Now I use the following code:
Code: Select all
procedure TForm1.SourceListBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var Stream : TMemoryStream;
i : SmallInt;
Ergi : String;
begin
if {(ssShift in Shift) and} (ssLeft in Shift) then begin
if Windows.DragDetect(SourceListBox.Handle, POINT(X,Y)) then begin // Panel2.Handle
with DMTextSource1.CustomFormatData do begin
// First clear the format data...
Clear;
Ergi := '';
for i := 0 to SourceListBox.Items.Count - 1 do
if SourceListBox.Selected[i] = True then
Ergi := Ergi + IntToStr(i) + '#';
Ergi := ergi + 'ListBoxSelectionEnd';
// ShowMessage(ergi);
Stream := TMemoryStream.Create;
SaveChartToStream(SourceChart, Stream, True, False);
Stream.Position := 0;
addFormat(DD_Name, Ergi + StreamToString(Stream)); // EncodeDoubleToString(aDouble)
Stream.Free;
end;
DMTextSource1.Execute; // Start the OLE drag
end;
end;
end;
But the problem is clicking the ListBox. If 2 or more series are selected and the user clicks into the listbox and holds the left mouse button down (in order to start the drag & Drop operation), the selection could be resetted.
Example:
The Listbox has the following entries:
Series 1
Series 2
Series 3
Series 4
The underlined series are the selected series.
Now the user clicks on Series 3 in order to start the Drag & Drop. Now Series 2 and 4 are deselected and only Series 3 is selected.
How can we prevent this behaviour?
And some notes about the drag & Drop. The normal Drag operation of the listbox is disabled (EnableDragSeries = False).