This component operates thus: it calls an event handler when it detects
the user has started a drag on the component it's paired with. This
event handler calls the component's Execute method to invoke OLE. When
execution returns to the event handler, the drag and drop is completed.
In my event handler, I load the file names corresponding to selected
items in the TListBox to a list maintained by the component.
Now the problem: when multiple items in the TListBox are selected by
holding down Shift and clicking, Windows shows only the first item
selected IS selected; the "selected" property returns false for all
other items, including selected ones. I've tried the Windows LB_GETSEL
message instead of the "selected" property and get the same outcome, so
I can see it's Windows and not Delphi. The items being missed are
colored in the manner of selected items.
Then I execute the component's Execute method, which permits dropping
of the single file name. Upon return, the "selected" property performs
as it should.
If I select multiple items with Ctrl instead of Shift, this problem
does not arise.
Does anybody have a clue? Source code for the component and my routine
will be furnished to anyone who thinks it'll help.
--
Thanks,
Elliott
"I don't want to achieve immortality through my
work. I want to achieve it by not dying." --
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
> Now the problem: when multiple items in the TListBox are selected by
> holding down Shift and clicking, Windows shows only the first item
> selected IS selected; the "selected" property returns false for all
> other items, including selected ones. I've tried the Windows LB_GETSEL
> message instead of the "selected" property and get the same outcome,
so
> I can see it's Windows and not Delphi. The items being missed are
> colored in the manner of selected items.
Here's how I solved my problem. It's a kludge, but it does the job:
=========================================================
// Find the first selected item.
if (shift key pressed) then
with ListBox do begin
for i := 0 to items.count - 1 do
if selected[i] then begin
if i < ItemIndex
then begin
SelStart := i;
SelEnd := ItemIndex;
end
else begin
SelStart := ItemIndex;
SelEnd := i;
end;
break;
end;
for i := SelStart to SelEnd do
Selected[i] := true;
end;
=========================================================
--
Hi !
What you're doing seems to be: in a range select, you have 2 known values: The first selected and
the ItemIndex. then you Select all items between those two.
But - the line
if (shift key pressed) then
indicates that you are doing this in a mouse event. Well, if you're in the MouseDown event, then
you're to quick. In OnMouseUp or OnClick, it's possible.
--
Bjoerge