Finding Selectionstart/selectionend in string/editorgadget

Just starting out? Need help? Post your questions and find answers here.
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

Finding Selectionstart/selectionend in string/editorgadget

Post 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
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Finding Selectionstart/selectionend in string/editorgadget

Post 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.
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

Re: Finding Selectionstart/selectionend in string/editorgadget

Post 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. :)
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Finding Selectionstart/selectionend in string/editorgadget

Post by skywalk »

Please read up and understand pointers.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
GenRabbit
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Dec 31, 2014 5:41 pm

Re: Finding Selectionstart/selectionend in string/editorgadget

Post 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.
Post Reply