Hi Tom,
How to do this is the rub!...:-) That's why I was hoping I could
piggyback an existing event. Is there a way to detect a right click
inside the OnCellClick event? If I could do this then I would be all
set!
Here's a similar situation with a statusbar and a number of panels on it & a
way to detect which panel was clicked.
unit main;
{
Implementing the OnClick event for a Panel on a TStatusBar Delphi control
http://delphi.about.com/od/vclusing/a/statuspanelclck.htm
}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TStatusForm = class(TForm)
StatusBar1: TStatusBar;
Memo1: TMemo;
procedure StatusBar1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
StatusForm: TStatusForm;
implementation
{$R *.dfm}
//StatusBar1 OnClick
procedure TStatusForm.StatusBar1Click(Sender: TObject);
var
mpt : TPoint; //mouse coordinate
x : integer;
j : integer;
panel : integer;
begin
//no StatusPanels defined
if (StatusBar1.SimplePanel) OR (StatusBar1.Panels.Count = 0) then
begin
Memo1.Lines.Add('Clicked on a StatusBar, no Panels');
Exit;
end;
//mouse position in screen coordinates
mpt := Mouse.CursorPos;
//mouse position in StatusBar coordinates
mpt := StatusBar1.ScreenToClient(mpt);
panel := -1;
x := 0;
for j := 0 to StatusBar1.Panels.Count - 1 do
begin
x := x + StatusBar1.Panels[j].Width;
if mpt.X < x then
begin
panel := j;
Break;
end;
end;
//clicked "after" the last panel -
//fake it as if the last one was clicked
if panel = -1 then panel := -1 + StatusBar1.Panels.Count;
Memo1.Lines.Add(Format('Clicked on StatusPanel %d',[panel]));
end;
end.
Cheers,
Charlie
[Non-text portions of this message have been removed]