Page 1 of 1

EditorGadget scrolling

Posted: Sat Dec 17, 2005 2:12 am
by kenmo
Hey, I've got a couple questions on editorgadgets, both concerning API (I'm assuming).

First, how do I enable word-wrap, and second, how can I automatically scroll it to the bottom when a line is added (like a ENSUREVISIBLE message for editorgadgets...)?

Thanks in advance.

Re: EditorGadget scrolling

Posted: Sat Dec 17, 2005 2:40 am
by ts-soft
kenmo wrote: First, how do I enable word-wrap

Code: Select all

SendMessage_(GadgetID(Gadget),#EM_SETTARGETDEVICE, #Null, Flag); Flag: 0 = WordWrap or 1 = no WordWrap

Posted: Sat Dec 17, 2005 3:00 am
by kenmo
Wow, fast and perfect answer! Thanks, man.

Posted: Sat Dec 17, 2005 1:41 pm
by srod
The following will scroll the editor gadget in order to show the last line in the control. However, if there are more lines than are visible, then it scrolls until the final line is at the very top of the client area.

The only way I can find of scrolling to put the last line at the bottom of the visible area involves some dirty scumy hit-testing in order to determine how many rows are visible within the control. I guess I shouldn't be surprised that I can't find an easy way of doing this, considering all the different font sizes which are possible etc.

Code: Select all

topvisible=sendmessage_(gadgetid(0), #EM_GETFIRSTVISIBLELINE,0,0)
sendmessage_(gadgetid(0), #EM_LINESCROLL, 0, countgadgetitems(0)-topvisible-1)

Posted: Sat Dec 17, 2005 10:56 pm
by kenmo
srod wrote:The only way I can find of scrolling to put the last line at the bottom of the visible area involves some dirty scumy hit-testing in order to determine how many rows are visible within the control. I guess I shouldn't be surprised that I can't find an easy way of doing this, considering all the different font sizes which are possible etc.
Actually that's specifically what I'm looking for... I assumed there WAS an easy way to do it. In any application's editor window, if you press CTRL+End it takes you to the bottom, but what message is performing that?

Posted: Sat Dec 17, 2005 11:04 pm
by srod
Doh!

How about this:

Code: Select all

SendMessage_(gadgetid(0), #EM_SETSEL,-1,-1)
Seems to do the job!

Posted: Sat Dec 17, 2005 11:11 pm
by kenmo
Haha, wow, I was not aware of that simple trick. Thank you.