Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I need a help working with applicationEventsMessage

Posted on 2006-10-31
10
Medium Priority
?
734 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
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!

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

772 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