Fórum botão mouse #411570
15/01/2012
0
Só funciona o botão esquerdo.
Como faço para detectar o direito e o meio tb.
Os tradicionais eventos VK_BUTTON ESQ, DIR e MIDDLE não funcionam
Grato pela força
procedure TForm1.Button1Click(Sender: TObject);
var
hTaskBar: THandle;
begin
// Se você quiser detectar o botão esquerdo do uso do mouse:
if GetAsyncKeyState (1) <> 0 then
begin
label1.Caption:=mouse esquerdo;
end;
end;

Alexandre
Curtir tópico
+ 0Posts
15/01/2012
Rafael Ribeiro
No evento OnMouseDown do form digite o seguinte código:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin case Button of mbLeft: begin Canvas.Brush.Color := clRed; Canvas.Rectangle(x-20,y-20,x+20,y+20) ; //DESENHARÁ UM RETANGULO VERMELHO ShowMessage(Botão Esquerdo!); end; mbRight: begin Canvas.Brush.Color := clBlue; Canvas.Rectangle(x-20,y-20,x+20,y+20) ; //DESENHARÁ UM RETANGULO AZUL ShowMessage(Botão Direito!); end; mbMiddle: begin Canvas.Brush.Color := clBlack; Canvas.Ellipse(x-20,y-20,x+20,y+20) ; //DESENHARÁ UMA ELIPSE PRETA ShowMessage(Botão Meio!); end; end; end; |
Abraços!
Rafael
Gostei + 0
15/01/2012
Alexandre
Funcionou correto.
Se precisar de algo em eletronica, só escrever
Abraços
Alexandre
Gostei + 0
15/01/2012
Rafael Ribeiro
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)