#include once "window9.bi"

Function GetSelectTextEditorGadget(ByVal gadget As Integer)As String Export
  Dim As CHARRANGE range
  Dim As Integer iLineBegin,iLineEnd
  Dim As HWND hw=GadgetID(gadget)
  SendMessage(hw, EM_EXGETSEL, 0, Cast(LPARAM, @range))
  iLineBegin = LineFromCharEditor(gadget)
  iLineEnd = LineFromCharEditor(gadget,range.cpMax)
  return Mid(GetGadgetText(gadget,7),range.cpMin+1+iLineBegin,(range.cpMax-range.cpMin) + (iLineEnd-iLineBegin))
End Function
