Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 16.03.05 09:01 
Hallo,
wie kann ich prüfen ob ich mit der welcher Maustaste ich doppelt auf ein LISTBOX item geklickt habe ?

ich habs so versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if button = mbLeft then
    isLeftClick:= True
  else
    isLeftClick:= False;
end;


und dann:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
  if isLeftClick = False then
    ShowMessage('OK');
  if ListBox1.ItemIndex > -1 then begin

    if SpeedButton5.Caption = '&Pause' then
      SpeedButton6Click(Sender);

    SpeedButton5Click(Sender);
  end;
end;

doch leider funktioniert diese möglichkeit nicht....

_________________
MFG
Michael Springwald, "kann kein englisch...."
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Mi 16.03.05 09:24 
Hallo,

mit Deinen beiden Proceduren mag ja alle stimmen, aber woher kommt die Information, was getan werden soll, wenn in der Procedur "TForm1.ListBox1MouseDown" der Boolsche Wert abgefragt wird ?


Mike
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 16.03.05 09:29 
was meinst du damit ?
bei listDown wird nur geprüft welcher butten gedrückt wurde und bei listdoppelclick wird dann geprüft welchen wert isLeftClick hat..... (so dachte ich es mir, doch leider geht das nicht)

_________________
MFG
Michael Springwald, "kann kein englisch...."
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Mi 16.03.05 09:34 
Schau dir in der Unit Control die Klasse TControl an. Dort findest du WMLButtonDblClk, WMRButtonDblClk, WMMButtonDblClk.

_________________
Ciao, Sprint.
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 16.03.05 09:38 
danke für den hinweis doch leider habe ich nur "Delphi 7 Personal Editon"

_________________
MFG
Michael Springwald, "kann kein englisch...."
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 16.03.05 09:39 
Mir fällt dau nur die dreckige Variante mit nem Timer ein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;   
  Shift: TShiftState; X, Y: Integer);   
begin   
  if button = mbRight then
  begin
    if NOT isRightClick then   
    begin
      isRightClick:= True;   
      timer1.enabled:=True;
      // interval ca 50-100ms, je nach gewünschter Doppelklick-Geschwindigkeit
    end else
    begin
      // Code für Rechts-Doppelklick
    end;
end;

procedure Timer1.OnTimer;
begin
  isRightClick:=False;
  Timer1.enabled:=False;
end;

_________________
We are, we were and will not be.
wdbee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 628
Erhaltene Danke: 1



BeitragVerfasst: Mi 16.03.05 09:43 
Ich habe das mal probiert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
  if oButton = mbLeft then
    Windows.Beep(200,20)
  else
    Windows.Beep(400,20);
end;

procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  oButton := Button;
end;


Ergebnis: ListBox1DblClick wird nur aufgerufen, wenn ich auf einen vorhandenen Eintrag doppelklicke! In einer leeren ListBox kommt nie etwas an!
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Mi 16.03.05 09:44 
user profile iconmimi hat folgendes geschrieben:
danke für den hinweis doch leider habe ich nur "Delphi 7 Personal Editon"

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TMyListBox = class(TListBox)
  private
    procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
    procedure WMRButtonDblClk(var Message: TWMRButtonDblClk); message WM_RBUTTONDBLCLK;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TMyListBox }

procedure TMyListBox.WMLButtonDblClk(var Message: TWMLButtonDblClk);
begin
  ShowMessage('Linke Maustaste');
  inherited;
end;

procedure TMyListBox.WMRButtonDblClk(var Message: TWMRButtonDblClk);
begin
  ShowMessage('Rechte Maustaste');
  inherited;
end;

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TMyListBox.Create(Self) do
  begin
    Parent := Self;
    SetBounds(10, 10, 150, 150);
    Items.Add('Test');
  end;
end;

end.

_________________
Ciao, Sprint.
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 17.03.05 09:00 
danke für eure hilfe ich werde es mal mit Sprint mhteode versuchen.

muss ich die einbinden wie eine eigene komponente ?
oder muss ich einfach nur das was du da geschrieben hast in mein qullcode einfügen und die Typ von der TListBox in TmyListBox ändern ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 17.03.05 09:46 
Es hat funktioniert so wie ich es mir vorgestellt hat, vielen dank :D

_________________
MFG
Michael Springwald, "kann kein englisch...."