Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

procedure WMRButtonDown(var Message: TMessage); message WM_RBUTTONDown; not work

Posted on 2001-07-17
4
Medium Priority
?
982 Views
Last Modified: 2008-02-01
In a form, I place a stringgrid, I wihs I am able to rightclick to highlight a row.

To achieve this, I use
procedure WMRButtonDown(var Message: TMessage); message WM_RBUTTONDown;

procedure TForm1.WMRButtonDown(var Message: TMessage);
begin
  postmessage(stringgrid1.Handle, WM_LBUTTONDown,mk_LButton, message.LParam);
  Application.ProcessMessages;
end;

But I found when I rightclick on the stringgrid, it doesn't go into the procedure.

But if I rightclick on the form, it goes into the procedure.

How to solve the problem?


Peter
0
Comment
Question by:petershaw8
4 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 6289322
Is there any reason you can't use StringGrid.OnMouseDown?
0
 

Accepted Solution

by:
Yunoshev earned 400 total points
ID: 6289383
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    BitBtn1: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 TMyGrid = class(TStringGrid)
   public
    { Public declarations }
    procedure WMRButtonDown(var Message: TMessage); message WM_RBUTTONDown;
 end;
var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TMyGrid.WMRButtonDown(var Message: TMessage);
begin
 
  You code there........
 
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
Var Grid:TMyGrid;
begin
 Grid := TMyGrid.Create(Form1);
 Grid.Parent := Form1;
 Grid.Top := 10;
 Grid.Left := 10;

end;

end.
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6289532
dear petershaw8,

i think onmousemove can help u too ( like scrapdog ).
i just give u detailed:

procedure TForm1.StringGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var i,j : longint;
    MyRect : TRect;
begin
  if (Button =  mbRight) then
  begin
    for i := 0 to StringGrid1.ColCount-1 do
    for j := 0 to StringGrid1.RowCount-1 do
    begin
    MyRect := StringGrid1.CellRect(i,j);
    if (MyRect.Top<=y) and (MyRect.Bottom>=y) and (MyRect.Left <=x) and (MyRect.right>=x) then
      showmessage('i ='+inttostr(i)+'j = '+inttostr(j));
      // now u can find selected cell by using
    end;
  end;
end;

i hope it can help u.

best regards
hamed

0
 
LVL 21

Expert Comment

by:gemarti
ID: 6289694
This sounds like you have accidently associated the event with the form instead of the string grid.

Check the OnMouseDown Event for the Form and see if it is pointing to the OnMouseDown Event for the String Grid. If it is then just delete it.

Then associate the OnMouseDown Event for the string grid with the event.

Just guessing.....
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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