BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TPopUp and TMemo...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Rory Walsh
Guest





PostPosted: Fri May 05, 2006 2:14 pm    Post subject: TPopUp and TMemo... Reply with 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?

Rory.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri May 05, 2006 9:11 pm    Post subject: Re: TPopUp and TMemo... Reply with quote



"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





PostPosted: Sat May 06, 2006 1:14 pm    Post subject: Re: TPopUp and TMemo... Reply with quote



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





PostPosted: Mon May 08, 2006 7:14 pm    Post subject: Re: TPopUp and TMemo... Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.