Solved

I need a help working with applicationEventsMessage

Posted on 2006-10-31
10
703 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

864 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

20 Experts available now in Live!

Get 1:1 Help Now