Page 2 of 2
Posted: Tue May 16, 2006 10:29 pm
by josku_x
Flype wrote:SetClipboardText(GetGadgetText(GetDlgCtrlID_(hWnd))) is 'assumed' to work only if hWnd comes from a StringGadget(), TextGadget(), EditorGadget(), etc...
the hWnd comes form an EditorGadget() but it fails here.
Posted: Tue May 16, 2006 10:38 pm
by srod
Is the editor gadget from a different process\application by any chance? If so, this method will not work.
Posted: Tue May 16, 2006 10:41 pm
by josku_x
srod wrote:Is the editor gadget from a different process\application by any chance? If so, this method will not work.
Yes, it's from another process/application. I wanted to have this feature because I am creating the "peek" program.
EDIT: is there any chance to get the text of an editorgadget of another process?
Posted: Tue May 16, 2006 10:48 pm
by srod
The API method should work in this case.
Sorry to send you off on a goose chase; I didn't realise the gadget was from another process.
Posted: Tue May 16, 2006 10:49 pm
by josku_x
no problem, but the api way (in your first post) doesn't work here. the program crashes before it readed the text.
Posted: Tue May 16, 2006 10:59 pm
by Flype
you should use SendMessage_() with #EM_GETTEXTEX and fill the structure GETTEXTEX.
Posted: Tue May 16, 2006 11:08 pm
by srod
The following works here.
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
Run the above program first. The next program will display the contents of the editor gadget in the already running program.
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
Posted: Tue May 16, 2006 11:21 pm
by dmoc
hint: they don't make it that easy

Posted: Tue May 16, 2006 11:30 pm
by Flype
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