Custom Popup Controls

This is the forum to discuss the Journal's content, article suggestions, etc.

Moderator: 2ffat

Post Reply
scfaria

Custom Popup Controls

Post by scfaria »

Article with above title (vol5/0105) showed how to make custom popups. I took this idea to put a drop down TListView into TStringGrid->Cells, but have not figured out how to find out which cell I am in so that I can copy the selected ListView1 item into the cell. I have the following code but this gives the wrong cell, if any cell at all:
<PRE>
void __fastcall TForm1::ListViewPopupFormClose(TObject* Sender, TCloseAction &Action) {
int r, c;
RECT ARect;
GetWindowRect(StringGrid->Handle, &ARect);
StringGrid->MouseToCell(ARect.left, ARect.top, c, r);
TListItem* Item = ListViewPopupForm_->ListView1->Selected;
if (Item) {
TCellObject* TCO = static_cast<TCellObject>(StringGrid->Objects[c][r]);
TCO->Text = Item->Caption;
TCO->Index = Item->Index;
}
}
</PRE>

This looks like I am mapping ARect from the top left corner of StringGrid: how do I figure out what cell I am in?
rlebeau
BCBJ Author
BCBJ Author
Posts: 1699
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: Custom Popup Controls

Post by rlebeau »

scfaria wrote:Article with above title (vol5/0105) showed how to make custom popups. I took this idea to put a drop down TListView into TStringGrid->Cells, but have not figured out how to find out which cell I am in so that I can copy the selected ListView1 item into the cell.


You should keep track of the cell before you display the ListView, not afterwards.

scfaria wrote:I have the following code but this gives the wrong cell, if any cell at all
...
This looks like I am mapping ARect from the top left corner of StringGrid


That is exactly what you are doing.

scfaria wrote:how do I figure out what cell I am in?


Use the Col and Row properties.
Remy Lebeau (TeamB)
Lebeau Software
scfaria

Post by scfaria »

I ended up taking the X, Y coords in the mousedown event and copying them into private X_, Y_ form vars and used the private vars to send the listview data to the proper cell. Thanks for info...
Post Reply