EditorGadget - determine selection

Just starting out? Need help? Post your questions and find answers here.
ZX80
Enthusiast
Enthusiast
Posts: 404
Joined: Mon Dec 12, 2016 1:37 pm

EditorGadget - determine selection

Post by ZX80 »

Good day to all.

Maybe someone has already encountered a similar problem ? Maybe someone has already solved this ?
I have an editor gadget. The user selects one line, several lines, or all lines. It doesn't matter if it was a mouse or another method (keyboard). These questions interest me. That is, when a button is pressed, I want to know whether all the text, several lines, or just one line is selected. Maybe even just part of a line. I would like to know the line numbers that were marked. All, even partially selected ones.

Thank you in advance for your answers.
Axolotl
Addict
Addict
Posts: 951
Joined: Wed Dec 31, 2008 3:36 pm

Re: EditorGadget - determine selection

Post by Axolotl »

You should really try the forum search first.
On Windows like this, on others search for Shardiks codes.

Code: Select all

Define Range.CHARRANGE
SendMessage_(GadgetID(Gadget), #EM_EXGETSEL, 0, @Range)  ; no return value, wParam not used  
;
; Range\cpMin ... Character position index immediately preceding the first character in the range. 
; Range\cpMax ... Character position immediately following the last character in the range. 
; 
; Get the Selected Text ..... 
;
;   Text$ = Space(Range\cpMax - Range\cpMin)  ; alloc string memory 
;   SendMessage_(GadgetID(Gadget), #EM_GETSELTEXT, 0, @Text$) 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
ZX80
Enthusiast
Enthusiast
Posts: 404
Joined: Mon Dec 12, 2016 1:37 pm

Re: EditorGadget - determine selection

Post by ZX80 »

Axolotl, thank you !

This is what is needed.
Post Reply