About RichEdit - Up and Down

Hmmm... I want to make a little modification in TRichEdit.
Here it is. Usually after we press arrow key down, our
cursor will move to the next line.
But I want to be like this:
* If I press arrow key down:
  The next line goes up, and replace the position of the
  current line (like scroll up).
* If I press arrow key up:
  The previous line goes down and replace the position of
  the current line (like scroll up).
This is the example:
1st line: I love experts-exchange.
2nd line: There are so many humble experts there.
3rd line: They will help newbies.

First condition in TRichEdit:
-------------------------------------- <- Border of RichEdit
I love experts-exchange.                
There are so many humble experts there.
They will help newbies.
---------------------------------------

After I press key down:
I love experts-exchange. ----> Outside RichEdit Screen
---------------------------------------
There are so many humble experts there.
They will help newbies.
---------------------------------------

After I press key down again:
I love experts-exchange.      ----> Outside RichEdit Screen
There are so many humble experts there.
---------------------------------------
They will help newbies.
---------------------------------------

Then I press key up:
I love experts-exchange. ----> Outside RichEdit Screen
---------------------------------------
There are so many humble experts there.
They will help newbies.
---------------------------------------

After I press again key up:
--------------------------------------
I love experts-exchange.                
There are so many humble experts there.
They will help newbies.
---------------------------------------

Hope you understand what I want.

Really need guidance of Delphi experts.

Hoping for the answer,

Daniel
LVL 7
daniel_cAsked:
Who is Participating?
 
jecksomConnect With a Mentor Commented:
Hi daniel_c!

use  em_scroll message , set memo1.enabled:=false and try this:


.skipped
type
  TForm1 = class(TForm)
    Memo1: TMemo;
  procedure wndproc(var Message: TMessage);override;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

.skipped

procedure Tform1.wndproc(var Message: TMessage);
begin
if message.msg=wm_keydown then
case message.wparam of
vk_down:SENDMESSAGE(memo1.handle,em_scroll,SB_LINEDOWN,0);
VK_UP:SENDMESSAGE(memo1.handle,em_scroll,SB_LINEUP,0);
END;
inherited;
end;

Jecksom

0
 
jecksomCommented:
Sorry in my example i used TMemo , but this method works with Treachedit as well.
Also, if you need to make strings empty when they not exist at bottom or top add manually
strings add when delete .

Best Regards ,
          Jecksom.

0
 
ZifNabCommented:
jecksom, It's em_VScroll. Zif. :-)
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ZifNabCommented:
oops, forget it, it's wm_VScroll, but thats something else.
0
 
daniel_cAuthor Commented:
Very fast answer!!!

Thanks Jecksom...
Thanks Tom...

Both of you are wonderful!!!

0
 
daniel_cAuthor Commented:
Hey experts, another problems came out now.
The answer is work when WordWrap is set to FALSE, but what if the WordWrap is set to TRUE??? I want a solution for it.
If wordwrap is set to TRUE, then may be 1 line can be broken to 2-3 lines.
So, what I want is to go to the next TRUE line (maybe skip 2-3 lines!)

Once again need your help...
0
 
jecksomCommented:
Hi again!

So you want to showup/down next line in case it's splitted with wordwrap and want to
scroll it as unsplitted one ?

Jecksom

0
 
daniel_cAuthor Commented:
yes Jecksom... that's what exactly I want...
I want to show up/down next line in case it's splitted with wordwrad and want to scroll it as unsplitted one!!!
Perfect understanding.
So, any solution for this?
0
 
jecksomCommented:
Hi Daniel!

Well i guess it possible , i'll try to make it today.

Best Regards,
                    Ivan.

0
 
daniel_cAuthor Commented:
Ok Ivan... or Jecksom???
Anyway, I will wait for it...
Thanks very much for your kindness...
I really appreciate it.
0
 
daniel_cAuthor Commented:
no solution yet?
should I put this as new question?
0
 
jecksomCommented:
New question ? hm, no , i think your main question good enough to be answered here.
I'm not answering b'coz , i didn't found standart method to do this , now i can
only offer override this with lines array like : unwordwrap text ->index unwraped lines->
wrap-> and then use scrolling with this array. O'coz it must be doing via onChange method.
But i still think there is something much more easy and will try to find it.

0
 
daniel_cAuthor Commented:
hmmm... yeah
it is more complicated now, isn't it?
i have given up, that's why I ask to this forum
0
All Courses

From novice to tech pro — start learning today.