Link to home
Start Free TrialLog in
Avatar of hidrau
hidrauFlag for Brazil

asked on

I need a help working with applicationEventsMessage

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;
Avatar of TName
TName

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.
Forgot the FormKeyUp... PLease add this:

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Pressed then
     Pressed:=False;
end;
Sorry, my fault, somehow hadn't realized that you are using MessageEvents. :/
Avatar of hidrau

ASKER

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

ok, I think it should be:

if (Msg.message = WM_RBUTTONDOWN) and (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_SHIFT) < 0)  then
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 :)
Avatar of hidrau

ASKER

I am gonna test
Avatar of hidrau

ASKER

If I need to include a key in this code, that is:

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

Thanks
ASKER CERTIFIED SOLUTION
Avatar of TName
TName

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hidrau

ASKER

Thank very much Tname