?
Solved

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

Posted on 2001-07-17
4
Medium Priority
?
954 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 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

Industry Leaders: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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