[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 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