Autor Beitrag
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Fr 04.08.06 00:39 
Hallo!

Ich wollte wissen wie es möglich ist, dass auch mit Rechtsklick ein Eintrag markiert wird.
Ich möchte nämlich für jeden Eintrag in der ListBox ein PopupMenu anpassen und wenn man mit Rechtsklick das PopupMenu aufruft sollte der Eintrag auch markiert werden da es
1. besser aussieht und
2. Es leichter für mich ist das Menü anzupassen :mrgreen:

Danke!


greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 04.08.06 00:46 
Jetzt betreibe ich einfach mal copy&paste aus dem Quelltext eines Projektes :mrgreen: :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TMainForm.UserListMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var APoint: TPoint;
    Index: integer;
begin
  if Button=mbRight then
  begin
    APoint.X := X;
    APoint.Y := Y;
    Index:=(Sender as TListBox).ItemAtPos(APoint, True);
    (Sender as TListBox).ItemIndex:=Index;
  end;
end;


Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 04.08.06 07:00 
Hallo,

als Kurzfassung:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TMainForm.MyListBoxMouseDown(Sender: TObject;  
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);  
begin  
  if Button = mbRight then
    with TListBox(Sender) do
      ItemIndex := ItemAtPos(Point(X,Y), True);
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )