How can I position the cursor within an editbox | Uniface 9 | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

—  Results per page  —








— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters
For a group of consecutive words like 'end of support' use Match phrase

sp_Feed Topic RSS sp_TopicIcon
How can I position the cursor within an editbox
09 May 2012
6:01 am
Avatar
ulrich-merkel
Frankfurt/Germany
Member
Forum Posts: 1683
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hallo Hartmut,

 

If I remember it well (tried it a long long time ago) the uniface macro statements works only in unifields.

Think I saw somwehere (in the undocumented features channels) there is a way to position the cursor
perhaps with fieldproperties or something similar.

 

Sometimes, one can abuse the "find" to go to the next line or so, but this is crippleware path of professionalism

 

09 May 2012
6:01 am
Avatar
hartmut.link
New Member
Forum Posts: 1
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hello,

does anybody know, how I can position the cursor within a multiline editbox ?

for example:

end of text, end of line, next line.

 

Thanks

 

16 Jun 2017
11:27 am
Avatar
rogerw
Member
Forum Posts: 232
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hi,

has someone a solution to position the cursor at the end of a RichEditBox?

Regards RogerW.

16 Jun 2017
4:41 pm
Avatar
diseli
Admin
Forum Posts: 810
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

rogerw said
Hi,

has someone a solution to position the cursor at the end of a RichEditBox?

Regards RogerW.  

Hi RogerW,

You could use the Windows USER32 function SendMessage for this. By sending the message EM_SETSEL to the RichEditBox widget you can set the position of the cursor and with the message EM_SCROLLCARET you can make sure that the cursor is visible (i.e. scrolls the cursor position into view). In order to send a message to a widget you need to obtain its window handle you can use the GetFocus function (that will retrieve the handle of the window that has the focus).

You can call the mentioned USER32 functions using  C Call-Out signatures. The required code would look like this:

newinstance “USER32”, hUser32
hWnd = hUser32->GetFocus()
hUser32->SendMessage(hWnd, <EM_SETSEL>, -1, -1) ; constant EM_SETSEL = 177
hUser32->SendMessage(hWnd, <EM_SCROLLCARET>, 0, 0) ; constant EM_SETSEL = 183

I’ve created a small sample that demonstrates the above code in “action” (see the Community Sample “Set cursor position in RichEditBox“). The sample includes the form CURSOR1 and the C Call-Out signature USER32. The form features two buttons (one to add text to the RichEditBox field and one to set the cursor). The above code can be found in the Asynchronous Interrupt trigger of the form and it’s triggered from the Field Gets Focus trigger.

Please note that I’ve created this sample using Uniface 9.7.03. But it should also work with any other Uniface 9.7 or 9.6 version.

Hope this helps.

Daniel

19 Jun 2017
12:29 pm
Avatar
rogerw
Member
Forum Posts: 232
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Thanks Daniel,

we will try it soon. I didn’t expect an answer on this question Surprised.

Regards RogerW.

31 Aug 2017
12:27 pm
Avatar
gianni
Member
Forum Posts: 250
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hi Daniel,

Nice, very nice!
As soon as I discovered this small example, I’ve immediately found a real usage scenario!
but … I can’t live on bread alone!

Is it also possible to mark a piece of text, like a character or a word or a line or from char 10 to char 20?
…and having also the option to choose backgroud color is asking too much?

Gianni

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 131

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ulrich-merkel: 1683

Iain Sharp: 605

Theo Neeskens: 339

gianni: 250

rogerw: 232

lalitpct: 197

istiller: 195

Knut: 173

-GHAN-: 171

sochaz: 165

Member Stats:

Guest Posters: 3

Members: 5469

Moderators: 0

Admins: 8

Forum Stats:

Groups: 1

Forums: 62

Topics: 2014

Posts: 8675

Newest Members:

Frankchets, jimchr, HerbertElaby, PhilipHar, Frankskync, FrankVag, LloydChelp, Vladcubre, BobbyFUT, Rickypaity

Administrators: admin: 23, Adrian Gosbell: 276, diseli: 810, Bob Maier: 3, Nico Peereboom: 60, Michael Rabone: 4, richiet: 406, JanCees: 28