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?
Custom Popup Controls
Moderator: 2ffat
Re: Custom Popup Controls
You should keep track of the cell before you display the ListView, not afterwards.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.
That is exactly what you are doing.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
Use the Col and Row properties.scfaria wrote:how do I figure out what cell I am in?
Remy Lebeau (TeamB)
Lebeau Software
Lebeau Software