Mega Code Archive

 
Categories / Delphi / Forms
 

How to detect a Mouse Click on the Caption of a form

Title: How to detect a Mouse Click on the Caption of a form private procedure WMNCRBUTTONDOWN(var msg: TMessage); message WM_NCRBUTTONDOWN; procedure WMNCLBUTTONDOWN(var msg: TMessage); message WM_NCLBUTTONDOWN; procedure WMNCLBUTTONDBLCLK(var msg: TMessage); message WM_NCLBUTTONDBLCLK; end; implementation procedure TForm1.WMNCRBUTTONDOWN(var msg: TMessage); begin if msg.wParam = HTCAPTION then Caption := 'Right Click!'; // Message.Result := 0; {to ignore the message} inherited; end; procedure TForm1.WMNCLBUTTONDOWN(var msg: TMessage); begin if msg.wParam = HTCAPTION then Caption := 'Left Click!'; // Message.Result := 0; {to ignore the message} inherited; end; procedure TForm1.WMNCLBUTTONDBLCLK(var msg: TMessage); begin if msg.wParam = HTCAPTION then Caption := 'Double Click!'; // Message.Result := 0; {to ignore the message} inherited; end;