Solved

Knowing on which character is klicked

Posted on 2002-06-19
5
146 Views
Last Modified: 2010-04-04
Hello,

Here are some questions I can't find a solution for.

1) Is it possible to store ± 1100 characters in one string?

2) Is it possible when clicked (or doubleclicked) on a string (text.property) in an edit field, to know on which character (count?) you clicked.  By example: if the value of the text property of an editfield is 'Jenny Jones' and you clicked with your mousepointer on the letter 'o' that the result you get is 8 (8 character of the text.property).

3) If there is a solution for question 2, is it then also possible to use it in a grid.  So when you clicked that you know on which record and in that record on which field and on which (count) character in that specific field.

Al solutions welcome.

Ka1a.

PS sorry for my poor English.
0
Comment
Question by:ka1a
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 7093393
1) yes
2) selstart is changed after one click->just get its value->pos := edit1.selstart+1; //selstart is zerobased
3) see 2, but not possible in all cases
0
 
LVL 17

Expert Comment

by:geobul
ID: 7093398
Hi,

1) Yes (up to 2MB)

2)
function GetClickedCharPos1(Sender: TObject): int64;
begin
  result := 0;
  if (Sender is TEdit) then
    result := (Sender as TEdit).SelStart + 1;
end;
// or
function GetClickedCharPos2(Sender: TObject): int64;
begin
  result := 0;
  if (Sender is TWinControl) then
    result := LoWord(SendMessage((Sender as TWinControl).Handle,EM_GETSEL,0,0)) + 1;
end;

procedure TForm1.Edit1Click(Sender: TObject);
begin
  ShowMessage(IntToStr(GetClickedCharPos1(Sender)));
end;

Regards, Geo
0
 
LVL 3

Expert Comment

by:lopem
ID: 7094959
listening
0
 

Author Comment

by:ka1a
ID: 7095082
Hi,

Thanks for the solutions.  That where the answers I was looking for.
It seems you both answered at the same time.  Is it possible for me to give you both 50 points and if yes, how do I have to do that.

Thanks.

Ka1a.
0
 
LVL 17

Expert Comment

by:geobul
ID: 7095121
Accept kretzschmar's comment as an answer here (50 points). He was the first who answered your question.

If you wish to give additional points to me, you may ask another question titled 'points for geobul'.

Regards, Geo
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month5 days, 10 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question