the hWnd comes form an EditorGadget() but it fails here.Flype wrote:SetClipboardText(GetGadgetText(GetDlgCtrlID_(hWnd))) is 'assumed' to work only if hWnd comes from a StringGadget(), TextGadget(), EditorGadget(), etc...
How to get text from an EditorGadget()? The API way...
Yes, it's from another process/application. I wanted to have this feature because I am creating the "peek" program.srod wrote:Is the editor gadget from a different process\application by any chance? If so, this method will not work.
EDIT: is there any chance to get the text of an editorgadget of another process?
The following works here.
Run the above program first. The next program will display the contents of the editor gadget in the already running program.
Code: Select all
;Make sure this program is running.
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
EditorGadget(0, 8, 8, 306, 133)
SetGadgetText(0,"HELLO!")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
hwnd=FindWindow_(#Null, "EditorGadget")
If hwnd
redit=FindWindowEx_(hwnd, #Null, "RichEdit20A", #Null)
tlen = SendMessage_(redit, #WM_GETTEXTLENGTH, 0, 0) + 1
edit$ = Space(tlen)
SendMessage_(redit, #WM_GETTEXT, tlen, @edit$)
Debug edit$
EndIf
I may look like a mule, but I'm not a complete ass.
this one should work even if richedit is in ascii or unicode.
Code: Select all
Enumeration ; GT_
#GT_DEFAULT
#GT_USECRLF
#GT_SELECTION
EndEnumeration
Enumeration ; GTL_
#GTL_DEFAULT = 0
#GTL_USECRLF = 1
#GTL_PRECISE = 2
#GTL_CLOSE = 4
#GTL_NUMCHARS = 8
#GTL_NUMBYTES = 16
EndEnumeration
Procedure.s GetRichEditText(hWindow.l, limit.l)
Protected text.s, gt.GETTEXTEX, gtl.GETTEXTLENGTHEX
If IsWindowUnicode_(hWindow)
gtl\codepage = 1200
Else
gtl\codepage = #CP_ACP
EndIf
gtl\flags = #GTL_DEFAULT|#GTL_NUMCHARS
gt\cb = SendMessage_(hWindow, #EM_GETTEXTLENGTHEX, @gtl, #Null)
gt\flags = #GT_DEFAULT
gt\codepage = gtl\codepage
text = Space(gt\cb)
SendMessage_(hWindow, #EM_GETTEXTEX, @gt, @text)
ProcedureReturn text
EndProcedure
If OpenWindow(0, 0, 0, 320, 240, "test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
EditorGadget(0, 5, 5, 200, 100)
EndIf
SetGadgetText(0, "hello world !")
Debug GetRichEditText(GadgetID(0))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer