[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to move the text pointer from right to left and vice versa?

Posted on 2006-05-24
17
Medium Priority
?
404 Views
Last Modified: 2010-04-05
hello,

i wanna move the text pointer by code from left side to right side, like using the left (CTRL+SHIFT)...
and the vice versa. i'm sure there is a code for this... isn't there ? :p
0
Comment
Question by:moayyad
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 16751105
I am thinking that you are reffering to a memo component. in this case use something like:
memo1.CaretPos := memo1.CaretPos - 1;
memo1.CaretPos := memo1.CaretPos +1;
0
 

Author Comment

by:moayyad
ID: 16751561
thanx 4 answer, but indeed i'm tring to do this in a text field :D
0
 
LVL 28

Expert Comment

by:2266180
ID: 16751954
testfield? you mean tedit .. no?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:moayyad
ID: 16752674
yes
0
 
LVL 28

Accepted Solution

by:
2266180 earned 252 total points
ID: 16755151
in that case the property you seek for is SelStart
edit1.selstart := edit1.selstart + 1;
edit1.selstart := edit1.selstart - 1;
0
 
LVL 10

Assisted Solution

by:atul_parmar
atul_parmar earned 248 total points
ID: 16761572
Hi,

Put the following lines to your textbox's onkeydown event. It will move the cursor from left to right when you press left CTRL+SHIFT and will move right to left when you press right CTRL+SHIFT

if ((GetKeyState(VK_LSHIFT) and $8000) > 0) and ((GetKeyState(VK_LCONTROL) and $8000) > 0) then
  Edit1.SelStart := Edit1.SelStart + 1
else if ((GetKeyState(VK_RSHIFT) and $8000) > 0) and ((GetKeyState(VK_RCONTROL) and $8000) > 0) then
  Edit1.SelStart := Edit1.SelStart - 1;

Atul
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16940686
Venabili, if you try to understand the question its about to move the cursor to left using left sided (ctrl+shift) and to right using right sided (ctrl+shift) and http:#16755151 doesn't confirms that.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 16940711
Yes and?
Your answer is the same as the one before you - use Edit1.SelStart
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16940721
Try the following.

var
  s, i : integer;
begin
  s := 10;
  for i := 0 to RichEdit1.Lines.Count - 1 do
    RichEdit1.Lines.Strings[i] := inttostr(s + i) + RichEdit1.Lines.Strings[i];
end;
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16940736
Sorry, I posted wrong lines.

My code is bit different it checks for the pressed keystroke and if it is left (ctrl+shift) or right (ctrl+shift) then only it moves accordingly

see
if ((GetKeyState(VK_LSHIFT) and $8000) > 0) and ((GetKeyState(VK_LCONTROL) and $8000) > 0) then
  Edit1.SelStart := Edit1.SelStart + 1
else if ((GetKeyState(VK_RSHIFT) and $8000) > 0) and ((GetKeyState(VK_RCONTROL) and $8000) > 0) then
  Edit1.SelStart := Edit1.SelStart - 1;

0
 
LVL 28

Expert Comment

by:2266180
ID: 16940901
I suggest a split. that should make everyone happy  :)
0
 
LVL 20

Expert Comment

by:Venabili
ID: 16940909
Split is ok for me
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16940913
Ciuly, that's fine but my concern is that if someone searches for a similar solution then he should be able to find the exact one.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 16941008
atul_parmar,

And they will in a split. The property name WAS one of the problems and you used the SAME in your code.

I hope you are not trying to say that you should get all the points? Because if you do, you may want to check the definition of split in the EE help page and probably what "team work" means in a dictionary.
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16941024
Venabili,

That's fine. :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 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