Custom Popup Controls

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

Moderator: 2ffat

Custom Popup Controls

Postby scfaria » Fri Nov 16, 2007 11:51 am

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?
scfaria
 

Re: Custom Popup Controls

Postby rlebeau » Tue Nov 27, 2007 9:14 pm

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
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1450
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Postby scfaria » Mon Dec 03, 2007 6:51 am

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...
scfaria
 


Return to Articles

Who is online

Users browsing this forum: No registered users and 1 guest

cron