 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rory Walsh Guest
|
Posted: Fri May 05, 2006 2:14 pm Post subject: TPopUp and TMemo... |
|
|
When I call a popup from a TMemo I would like the text caret to go to
the position of the cursor, before the popup appears, any ideas on how
to do this?
Rory. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri May 05, 2006 9:11 pm Post subject: Re: TPopUp and TMemo... |
|
|
"Rory Walsh" <rorywalsh (AT) ear (DOT) ie> wrote in message
news:445b5a8f (AT) newsgroups (DOT) borland.com...
| Quote: | When I call a popup from a TMemo I would like the text caret to
go to the position of the cursor, before the popup appears, any
ideas on how to do this?
|
Triy updating the Memo's SelStart property in the PopupMenu's OnPopup event?
Gambit |
|
| Back to top |
|
 |
Rory Walsh Guest
|
Posted: Sat May 06, 2006 1:14 pm Post subject: Re: TPopUp and TMemo... |
|
|
I will try that, do you mean once the user clicks the OnPopup event will
calculate from the position of the cursor where to put the caret? Thanks
for the help.
Rory.
Remy Lebeau (TeamB) wrote:
| Quote: | "Rory Walsh" <rorywalsh (AT) ear (DOT) ie> wrote in message
news:445b5a8f (AT) newsgroups (DOT) borland.com...
When I call a popup from a TMemo I would like the text caret to
go to the position of the cursor, before the popup appears, any
ideas on how to do this?
Triy updating the Memo's SelStart property in the PopupMenu's OnPopup event?
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon May 08, 2006 7:14 pm Post subject: Re: TPopUp and TMemo... |
|
|
"Rory Walsh" <rorywalsh (AT) ear (DOT) ie> wrote in message
news:445c9dee (AT) newsgroups (DOT) borland.com...
| Quote: | do you mean once the user clicks the OnPopup event will calculate
from the position of the cursor where to put the caret?
|
TPopupMenu does not provide you with that value, so you have to calculate it
manually. Retreive the cursor's current screen position, convert it into
client coordinates within the Memo, then convert the coordinates into a
character offset, and then finally set the SelStart property. For example:
void __fastcall TForm1::PopupMenu1Popup(TObject *Sender)
{
// you can ignore this part if the Memo is the only
// one ever showing the popup menu ...
if( PopupMenu1->PopupComponent == Memo1 )
{
TPoint p = Memo1->ScreenToClient(Mouse->CursorPos);
int pos = Memo1->Perform(EM_CHARFROMPOS, 0, MAKELPARAM(p.x,
p.y));
if( pos > -1 )
Memo1->SelStart = LOWORD(pos);
}
//...
}
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|