Hola Toni-2006.
Se me ocurre que podrías hacer:
Código Delphi
[-]
procedure TForm1.FormCreate(Sender: TObject);
begin
with FileListBox1 do
begin
MultiSelect:= False;
PopupMenu := nil;
end;
end;;
function SelectedItemIndex(FLB: TFileListBox): Integer;
var
i: Integer;
begin
Result:= -1;
for i:= 0 to FLB.Items.Count-1 do
if FLB.Selected[i] then
begin
Result:= i;
Exit;
end;
end;
procedure TForm1.FileListBox1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
P : TPoint;
SI: Integer;
begin
SI := SelectedItemIndex(FileListBox1);
if (ssRight in Shift) and (SI <> -1) then
begin
P.X:= FileListBox1.Left + X;
P.Y:= FileListBox1.Top + SI * FileListBox1.ItemHeight + FileListBox1.ItemHeight;
P := ClientToScreen(P);
PopupMenu1.Popup(P.X, P.Y);
end;
end;
Otra opción es usar el evento
OnMouseMove para que el ítem quede seleccionado cuando el mouse pasa por encima:
Código Delphi
[-]
procedure TForm1.FileListBox1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
with Sender as TFileListBox do
ItemIndex := ItemAtPos(Point(x,y), True);
end;
Pero de este modo no se seleccióna el ítem mediante el clíck del mouse...
Saludos
