Ver Mensaje Individual
  #2  
Antiguo 26-11-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Toni-2006.

Se me ocurre que podrías hacer:
Código Delphi [-]
// Desactivar selección múltiple y desasociar popupmenu
procedure TForm1.FormCreate(Sender: TObject);
begin
  with FileListBox1 do
  begin
    MultiSelect:= False;
    PopupMenu  := nil;
  end;
end;;

// Obtener el ítem seleccionado
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
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita