Solved

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

Posted on 2001-07-17
4
928 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 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

18 Experts available now in Live!

Get 1:1 Help Now