How to get text from an EditorGadget()? The API way...
How to get text from an EditorGadget()? The API way...
Hello!
I am creating a "peek" program just like WinPeek with that you can view and edit stuff of other windows. However, I stumbled in this situation that I don't know how to get text from an EditorGadget() (RichEdit20A).
I tried using GetWindowText_(), but it returns an empty string. But if I use GetWindowText_() with another control like a button, then it works.
So, it's not an issue with my code, but with the Win API.
Thanks
I am creating a "peek" program just like WinPeek with that you can view and edit stuff of other windows. However, I stumbled in this situation that I don't know how to get text from an EditorGadget() (RichEdit20A).
I tried using GetWindowText_(), but it returns an empty string. But if I use GetWindowText_() with another control like a button, then it works.
So, it's not an issue with my code, but with the Win API.
Thanks
You can use the following to retrieve the text in one great 'lump'! This will include any control codes separating individual lines though.
Why not GetGadgetText() though?
Code: Select all
tlen = SendMessage_(GadgetID(#edit), #WM_GETTEXTLENGTH, 0, 0) + 1
edit$ = Space(tlen)
SendMessage_(GadgetID(#edit), #WM_GETTEXT, tlen, @edit$)
I may look like a mule, but I'm not a complete ass.
does this mean if you have the handle, for example of the input gadget for the URL in let's say firefox, and you do ctrlid = GetDlgCtrlID_(handlehere) , would I be able to take the ctrlid result and use it in gadget functions?Flype wrote:You may be interested in this api function :
CtrlID = GetDlgCtrlID_( GadgetID(100) )
Then CtrlID should be 100.
Oh man! I am so dumb. Yesterday I was working on a project with Pelles C using dialogs. And I knew that there was this GetDlgCtrlID_() function..Flype wrote:You may be interested in this api function :
CtrlID = GetDlgCtrlID_( GadgetID(100) )
Then CtrlID should be 100.
Thanks! Now I am enjoying the affair between PB and API more and more!
In short, no! The control will mean nothing to PB as it will have no record of having created the control. In this case it is API all the way!Matt wrote:does this mean if you have the handle, for example of the input gadget for the URL in let's say firefox, and you do ctrlid = GetDlgCtrlID_(handlehere) , would I be able to take the ctrlid result and use it in gadget functions?
I may look like a mule, but I'm not a complete ass.
Josku_x, not entire sure what just bit your backside there? My previous post was entered before I noticed your post.
Besides, did you even read my original post on the subject of GetDlgCtrlID_() ? Let me just repeat it for you:
GetDlgCtrlID_(ehWnd) will return the PB identifier for the gadget with the window's handle ehWnd etc. This assumes of course that you created the rich edit control with PB commands.
I guess you missed the 'assume...' part.
Besides, did you even read my original post on the subject of GetDlgCtrlID_() ? Let me just repeat it for you:
GetDlgCtrlID_(ehWnd) will return the PB identifier for the gadget with the window's handle ehWnd etc. This assumes of course that you created the rich edit control with PB commands.
I guess you missed the 'assume...' part.
I may look like a mule, but I'm not a complete ass.
Sorry, yeah I didn't notice the 'assume' part.....................................................................................................
...........................................................................................................
...........................................................................................................
...........................................................................................................
.................................
...........................................................................................................
...........................................................................................................
...........................................................................................................
.................................
BTW: I can't get my code to work. I am using this code:
After I set the hWnd handle to the RichEdit (I get the handle through WinPeek) the program crashes and nothing happens.. Is it expected to be like this?
Code: Select all
SetClipboardText(GetGadgetText(GetDlgCtrlID_(hWnd)))
SetClipboardText(GetGadgetText(GetDlgCtrlID_(hWnd))) is 'assumed' to work only if hWnd comes from a StringGadget(), TextGadget(), EditorGadget(), etc...
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