Page 1 of 1

Finding Selectionstart/selectionend in string/editorgadget

Posted: Wed Dec 04, 2024 1:17 am
by GenRabbit
I'm trying to find is if there is a way to get the selectionstart and selectionend when you mark some text in and string/editorgadget,

I know how to set the selectionstart and selectionend. Googling usually gives you like;
start = gagdet.Selectionstart
TheEnd = gagdet.SelectionEnd

Something asfar as I know PB does not support. So is there a way to get these two values?

So far I've tested with this;

Code: Select all

Protected.i wp = 0, lp = -1
SendMessage_(GadgetID(#TxtMinutesInHour),#EM_GETSEL,wp,lp)
and other combos of wp and lp.
but whatever wp/lp returns is what I put into it, not the first and last position as expected of market text

Re: Finding Selectionstart/selectionend in string/editorgadget

Posted: Wed Dec 04, 2024 2:33 am
by Demivec
GenRabbit wrote: Wed Dec 04, 2024 1:17 am I'm trying to find is if there is a way to get the selectionstart and selectionend when you mark some text in and string/editorgadget,

I know how to set the selectionstart and selectionend. Googling usually gives you like;
start = gagdet.Selectionstart
TheEnd = gagdet.SelectionEnd

Something asfar as I know PB does not support. So is there a way to get these two values?

So far I've tested with this;

Code: Select all

Protected.i wp = 0, lp = -1
SendMessage_(GadgetID(#TxtMinutesInHour),#EM_GETSEL,wp,lp)
and other combos of wp and lp.
but whatever wp/lp returns is what I put into it, not the first and last position as expected of market text
Use:

Code: Select all

Protected.i wp = 0, lp = 0
SendMessage_(GadgetID(#TxtMinutesInHour), #EM_GETSEL, @wp, @lp)
The return values will be in wp and lp.

Re: Finding Selectionstart/selectionend in string/editorgadget

Posted: Wed Dec 04, 2024 6:40 am
by GenRabbit
Doh, So basically I have to use @ with every API call where it returns values like that. Point to the value, do not provide the value directly.
Thanks it did it. :)

Re: Finding Selectionstart/selectionend in string/editorgadget

Posted: Wed Dec 04, 2024 2:44 pm
by skywalk
Please read up and understand pointers.

Re: Finding Selectionstart/selectionend in string/editorgadget

Posted: Fri Dec 06, 2024 9:50 pm
by GenRabbit
I have done something more like this before. I just totally forgot that the wparam/lparam/sparam is mostly, if not always a pointer, and not the value itself.