Jump to content


Photo

Understanding GetRowAtPos


  • Please log in to reply
1 reply to this topic

#1 qi130

qi130
  • Members
  • 23 posts

Posted 26 October 2007 - 10:45 AM

I try the following code to retrieve, through a pop-up option, the row number on which I've right-clicked:
CODE
procedure TOKBottomDlg1.Cloner1Click(Sender: TObject);
var i,j:Integer;
mpos: TPoint;
begin
GetCursorPos(mpos);
mpos:=NextGrid1.ScreenToClient(mpos);
i:=NextGrid1.GetRowAtPos(mpos.X,mpos.Y);
if i=-1 then Exit;
NextGrid1.AddRow(1);
...
end;


There is 1 row in the grid, but when I right-click on it, GetRowAtPos return -1 mad.gif

I guess it's because the pop-up option is not over the row...

So, how can I retrieve this f****** row number ?

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 26 October 2007 - 02:26 PM

Hello,

Maybe you need to first retreive row and then show a popup? Next example work fine:

CODE
procedure TForm1.NextGrid1Click(Sender: TObject);
var
  i, j:Integer;
  mpos: TPoint;
begin
  GetCursorPos(mpos);
  mpos := NextGrid1.ScreenToClient(mpos);
  i := NextGrid1.GetRowAtPos(mpos.X,mpos.Y);
  Caption := IntToStr(i);
end;


Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users