Solved

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

Posted on 2001-07-17
4
945 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
[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
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 100 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

Independent Software Vendors: 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

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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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