Solved

Knowing on which character is klicked

Posted on 2002-06-19
5
143 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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