It is currently Tue Feb 25, 2020 1:37 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to get text from an EditorGadget()? The API way...
PostPosted: Tue May 16, 2006 8:03 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 8:30 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10577
Location: Beyond the pale...
You can use the following to retrieve the text in one great 'lump'! This will include any control codes separating individual lines though.

Code:
tlen = SendMessage_(GadgetID(#edit), #WM_GETTEXTLENGTH, 0, 0) + 1
edit$ = Space(tlen)
SendMessage_(GadgetID(#edit), #WM_GETTEXT, tlen, @edit$)


Why not GetGadgetText() though?

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 8:33 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
THanks srod!

srod wrote:
Why not GetGadgetText() though?

If I retrieve a system handle to a control, I can't use PB commands with it, as PB commands need the #number of the gadget and not the #handle. Capich? :D


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 8:51 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1534
Location: In a long distant galaxy
You may be interested in this api function :

CtrlID = GetDlgCtrlID_( GadgetID(100) )

Then CtrlID should be 100.

_________________
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 8:52 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10577
Location: Beyond the pale...
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 may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 8:54 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10577
Location: Beyond the pale...
Sorry flype, I must have posted at the same time! :D

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 9:24 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat May 21, 2005 1:08 am
Posts: 447
Location: USA
Flype wrote:
You may be interested in this api function :

CtrlID = GetDlgCtrlID_( GadgetID(100) )

Then CtrlID should be 100.


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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 9:36 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
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.. :oops:

Thanks! Now I am enjoying the affair between PB and API more and more!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 9:39 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
-REMOVED-


Last edited by josku_x on Tue May 16, 2006 9:42 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 9:41 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10577
Location: Beyond the pale...
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?


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!

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 9:44 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
Mr. IKnowEverything (srod), why did you want to tell me then that there is the GetDlgCtrlID_() API function? If I can't use PB commands with the returned CtrlID, what's the use of it then?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 10:00 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10577
Location: Beyond the pale...
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.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 10:03 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
Sorry, yeah I didn't notice the 'assume' part.....................................................................................................
...........................................................................................................
...........................................................................................................
...........................................................................................................
................................. :?:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 10:13 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Sep 24, 2005 2:08 pm
Posts: 997
BTW: I can't get my code to work. I am using this code:
Code:
SetClipboardText(GetGadgetText(GetDlgCtrlID_(hWnd)))


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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 16, 2006 10:28 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1534
Location: In a long distant galaxy
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye