Announcement

Collapse
No announcement yet.

Mausklick und Strg

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mausklick und Strg

    Hi.
    Gibt es eine Möglichkeit, beim Mausklick auf einen Button
    auch auf das Drücken der Strg - Taste zu reagieren?
    Damit meine ich nur das OnClick - Ereignis.
    Jan U.

  • #2
    Hi,

    ich dir bereits geantwortet, aber es erscheint bei mir nicht hier. Also noch mal ganz kurz. Du erzeugst zwei Erreignisse. Ein OnClick und ein KeyPress oder OnKeyDown. Im OnClick Ereignis rufst du das OnKeyDown Ereignis ab und befragst einfach den Parameter Key.

    Gruß Philip

    Comment


    • #3
      <html>

      <head>
      <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1">
      <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
      <title>Normale Seite ohne Titel</title>
      </head>

      <body bgcolor="#FFFFFF">

      <p>Hallo Jan, schau Dir mal die Hilfe zu <font color="#FF0000"><strong>OnMouseMove</strong></font>,
      <font color="#FF0000"><strong>OnMouseDown</strong></font> und all
      diesen Ereignissen an. Wozu ist da wohl der Parameter <font
      color="#FF0000"><strong>TShiftState</strong></font> gedacht ?
      Wenn Du mit der linken Maustaste auf einen Button klickst, wird
      zuerst ein OnMouseDown, dann ein OnClick, und zuletzt ein
      OnMouseUp ausgelöst. Zum Testen erstell Dir ein Formular mit
      einem Button und einer ListBox, und gib in die Button-Ereignisse
      folgenden Code ein:</p>

      <pre>
      <strong>void</strong> <strong>__fastcall</strong> TForm1::Button1Click(TObject *Sender)
      {
      ListBox1-&gt;Items-&gt;Add(<font color="#000080">&quot;OnClick&quot;</font>);
      }

      <strong>void</strong> <strong>__fastcall</strong> TForm1::Button1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, <strong>int</strong> X, <strong>int</strong> Y)
      {
      LPSTR Text=<strong>new</strong> <strong>char</strong>[60];
      strcpy(Text,<font color="#000080">&quot;OnMouseUp &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssDouble</font>)) strcat(Text,<font
      color="#000080">&quot;Doppelklick &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssLeft</font>)) strcat(Text,<font
      color="#000080">&quot;linke Maustaste &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssRight</font>)) strcat(Text,<font
      color="#000080">&quot;rechte Maustaste &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssMiddle</font>)) strcat(Text,<font
      color="#000080">&quot;mittlere Maustaste &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssShift</font>)) strcat(Text,<font
      color="#000080">&quot;+Umschalt-Taste &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssCtrl</font>)) strcat(Text,<font
      color="#000080">&quot;+Ctrl-Taste &quot;</font>);
      <strong>if</strong> (Shift.Contains(<font color="#0000FF">ssAlt</font>)) strcat(Text,<font
      color="#000080">&quot;+Alt-Taste &quot;</font>);
      ListBox1-&gt;Items-&gt;Add(Text);
      <strong>delete</strong> Text;
      }

      <strong>void</strong> <strong>__fastcall</strong> TForm1::Button1MouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, <strong>int</strong> X, <strong>int</strong> Y)
      {
      ListBox1-&gt;Items-&gt;Add(<font color="#000080">&quot;OnMouseUp&quot;</font>);
      }
      </pre>
      </body>
      </html&gt
      Günther

      Comment

      Working...
      X