Page 1 of 1
get selected text of editor gadget
Posted: Sun Sep 12, 2004 7:42 am
by Yian_The_Craft
title says it all

Posted: Sun Sep 12, 2004 8:44 am
by Dare2
Edit:
Sorry, didn't realise this was a feature request, hence the code below.
(I used "view posts since last visit" and didn't check the forum name.)
Anyhow, just in case it was a request for code, will leave the code below.
Code: Select all
winID=OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar,"SOMETHING")
If winID
gadList=CreateGadgetList(WindowID(0))
If gadList
edGadID=EditorGadget(1,5,5,290,290)
If edGadID
lastSz=0 ; klurge - to stop debug window scrolling until change
lastCh=0 ; klurge - to stop debug window scrolling until change
Repeat
Event = WaitWindowEvent()
; ------- DEFINE YOUR OWN TRIGGER
; This triggers when any selection done.
SendMessage_(edGadID,#EM_EXGETSEL,0,Range.CHARRANGE)
siz=Range\cpMax-Range\cpMin
If siz<>0 And (lastSz<>siz Or lastCh<>Range\cpMin)
lastSz=siz
lastCh=Range\cpMin
w.s=Space(siz*2)
SendMessage_(edGadID,#EM_GETSELTEXT,0,w)
Debug Str(siz)+": "+w
EndIf
Until Event = #PB_EventCloseWindow
EndIf
EndIf
EndIf
Posted: Sun Sep 12, 2004 11:23 am
by Yian_The_Craft
many thanks!

But how did you think of that? I'm a bit confused since you don't seem to use stuff in the manual...like sendmessage_ and #EM_GETSELTEXT
Posted: Sun Sep 12, 2004 11:43 am
by Dare2
Hi Yian_The_Craft.
First, wish I could say I worked it out but I didn't. I learned it and other things from the smarter folk using this forum.
Second, it is a winapi call, not a PureBasic command. PureBasic, or the registered version, allows for calls to windows functions. All you need to to is stick a "_" after the windows function name, eg, SendMessage(.. becomes SendMessage_(..
You can find these functions in the windows SDK (downloadable from MS) or the older help file (sure to be a link to that somewhere in the forums).
If you read through the forums you will find bucketloads of useful stuff from the gurus here. You can also download a massive amount of code from
http://www.purearea.net (the code archive).
The forum for asking questions is the beginners forum, help comes faster on that forum (this one is requests to Fred to add functionality to PureBasic) After I first answered your post and then saw where it was posted I nearly deleted my response because I thought you might be requesting that this be added to functionality, eg something like:
- w.s=GetEditorSelectedText(#Gadget)
Anyhow, welcome to the boards and success to you.

Posted: Sun Sep 12, 2004 12:02 pm
by Yian_The_Craft
Thanks,it would be good if it was added to functionality.