Solved

I need a help working with applicationEventsMessage

Posted on 2006-10-31
10
701 Views
Last Modified: 2012-06-27
Hello guys,
I would like to trigger a code after the user click ctrl + shift and  WM_RBUTTONDOWN, but I am not getting any success. I need this help. Thanks

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
begin
  If (Msg.message = WM_RBUTTONDOWN)  and (msg.message = ?????)  Then showMessage('ok')
end;
0
Comment
Question by:hidrau
  • 6
  • 4
10 Comments
 
LVL 28

Expert Comment

by:TName
ID: 17841198
Hi, you could do something like this:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    Pressed:Boolean;
    procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMRButtonDown(var Message: TWMRButtonDown);
begin
  if Pressed then begin
    ShowMessage('OK');
    Pressed:=False;
  end;
end;

procedure TForm1.FormCreate(Sender:TObject);
begin
   Pressed:=False;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (ssShift in Shift) and (ssCtrl in Shift) then
    Pressed:=True;
end;

end.
0
 
LVL 28

Expert Comment

by:TName
ID: 17841216
Forgot the FormKeyUp... PLease add this:

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Pressed then
     Pressed:=False;
end;
0
 
LVL 28

Expert Comment

by:TName
ID: 17841248
Sorry, my fault, somehow hadn't realized that you are using MessageEvents. :/
0
 
LVL 1

Author Comment

by:hidrau
ID: 17841250
I need to use in application because this must be in all application.

My application has more than 100 forms and it is impossible to place one for each form.

You see
0
 
LVL 28

Expert Comment

by:TName
ID: 17841362

ok, I think it should be:

if (Msg.message = WM_RBUTTONDOWN) and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_SHIFT) < 0)  then
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 28

Expert Comment

by:TName
ID: 17841395
e.g.:

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  if (Msg.message = WM_RBUTTONDOWN) and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_SHIFT) < 0)  then
    ShowMessage('ok');
end;

And I meant ApplicationEvents of course :)
0
 
LVL 1

Author Comment

by:hidrau
ID: 17841458
I am gonna test
0
 
LVL 1

Author Comment

by:hidrau
ID: 17841470
If I need to include a key in this code, that is:

if ctrl + shift + z and WM_RBUTTONDOWN, what should I add?

Thanks
0
 
LVL 28

Accepted Solution

by:
TName earned 500 total points
ID: 17841529
This should work (it has to be an uppercase 'Z' because the shift key is pressed...)

if (Msg.message = WM_RBUTTONDOWN) and (GetKeyState(VK_CONTROL) < 0) and
     (GetKeyState(VK_SHIFT) < 0) and (GetKeyState(Ord('Z')) < 0) then
        ShowMessage('ok');
0
 
LVL 1

Author Comment

by:hidrau
ID: 17841855
Thank very much Tname
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now