Solved

I need a help working with applicationEventsMessage

Posted on 2006-10-31
10
714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create Database on Android via Delphi dbExpress 3 129
Breakpoint doesn't stop in my variable 3 36
How to make Sign in, using Clientdataset? 1 33
shape, triangle, dbctrlgrid 3 31
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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