BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting text from within a window

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Jeff
Guest





PostPosted: Wed Aug 10, 2005 4:35 pm    Post subject: Getting text from within a window Reply with quote



I'm trying to get static text that is in a window. I've got a handle to the
window, but every thing I've tried (i.e. GetWindowText(), WM_GETTEXT) has
only retrieved the caption. How can I retrieve the text of a label within
the window?

Here's a code snippet from my last attempt:

SendMessage(hWindow, WM_GETTEXT, GetWindowTextLength(hWindow) + 1,
(LPARAM)ptr_chrTitle);

Please help,
Jeff


Back to top
Gary Setter
Guest





PostPosted: Wed Aug 10, 2005 4:43 pm    Post subject: Re: Getting text from within a window Reply with quote




"Jeff" <Jeff (AT) nospam (DOT) com> wrote

Quote:
I'm trying to get static text that is in a window. I've got a handle to
the
window, but every thing I've tried (i.e. GetWindowText(), WM_GETTEXT) has
only retrieved the caption. How can I retrieve the text of a label within
the window?

Here's a code snippet from my last attempt:

SendMessage(hWindow, WM_GETTEXT, GetWindowTextLength(hWindow) + 1,
(LPARAM)ptr_chrTitle);

Can you get the handle of the lable? Maybe you can tell use a bit more about

how you have set things up.

Gary


Back to top
Alan Bellingham
Guest





PostPosted: Wed Aug 10, 2005 4:45 pm    Post subject: Re: Getting text from within a window Reply with quote



"Jeff" <Jeff (AT) nospam (DOT) com> wrote:

Quote:
I'm trying to get static text that is in a window. I've got a handle to the
window, but every thing I've tried (i.e. GetWindowText(), WM_GETTEXT) has
only retrieved the caption. How can I retrieve the text of a label within
the window?

Send the message (or call GetWindowText()) with the window handle of the
label, not of its parent.

This assumes the label is a window. If not, then you're probably out of
luck unless the parent window exposes a special API for the purpose.
IIRC, the VCL TLabel is not a window, but rather something the parent
window draws when required.
Alan Bellingham
--
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK

Back to top
Jeff
Guest





PostPosted: Wed Aug 10, 2005 4:49 pm    Post subject: Re: Getting text from within a window Reply with quote

How would I get a handle to the label? I've used FindWindow() to get the
window handle, but I'm not sure how to get handles to its children?

"Alan Bellingham" <alanb (AT) episys (DOT) com> wrote

Quote:
"Jeff" <Jeff (AT) nospam (DOT) com> wrote:

I'm trying to get static text that is in a window. I've got a handle to
the
window, but every thing I've tried (i.e. GetWindowText(), WM_GETTEXT) has
only retrieved the caption. How can I retrieve the text of a label within
the window?

Send the message (or call GetWindowText()) with the window handle of the
label, not of its parent.

This assumes the label is a window. If not, then you're probably out of
luck unless the parent window exposes a special API for the purpose.
IIRC, the VCL TLabel is not a window, but rather something the parent
window draws when required.
Alan Bellingham
--
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Aug 10, 2005 5:46 pm    Post subject: Re: Getting text from within a window Reply with quote


"Jeff" <Jeff (AT) nospam (DOT) com> wrote


Quote:
I'm trying to get static text that is in a window. I've got a handle
to the window, but every thing I've tried (i.e. GetWindowText(),
WM_GETTEXT) has only retrieved the caption. How can I
retrieve the text of a label within the window?

After you get the handle of the window that the label belongs to, you need
to then get the handle of the label itself. Only then can you access the
label directly and do whatever you want with it. Look at FindWindowEx(),
EnumChildWindows(), or GetDlgItem() to retreive the label's handle. If the
label is not placed on the window directly, but rather is on a container
such as a panel, then you will have to drill down the parent/child hierarchy
until you reach the container that the label is actually in.


Gambit



Back to top
tinyabs
Guest





PostPosted: Wed Aug 10, 2005 6:38 pm    Post subject: Re: Getting text from within a window Reply with quote

Alternatively, you can try WindowFromPoint().


Back to top
Jeff
Guest





PostPosted: Wed Aug 10, 2005 7:51 pm    Post subject: Re: Getting text from within a window Reply with quote

Thank you, I'll look into this.

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote

Quote:

"Jeff" <Jeff (AT) nospam (DOT) com> wrote in message
news:42fa2cc5 (AT) newsgroups (DOT) borland.com...

I'm trying to get static text that is in a window. I've got a handle
to the window, but every thing I've tried (i.e. GetWindowText(),
WM_GETTEXT) has only retrieved the caption. How can I
retrieve the text of a label within the window?

After you get the handle of the window that the label belongs to, you need
to then get the handle of the label itself. Only then can you access the
label directly and do whatever you want with it. Look at FindWindowEx(),
EnumChildWindows(), or GetDlgItem() to retreive the label's handle. If
the
label is not placed on the window directly, but rather is on a container
such as a panel, then you will have to drill down the parent/child
hierarchy
until you reach the container that the label is actually in.


Gambit





Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Aug 10, 2005 9:27 pm    Post subject: Re: Getting text from within a window Reply with quote


"tinyabs" <nospam (AT) me (DOT) com> wrote


Quote:
Alternatively, you can try WindowFromPoint().

That will only find the top-level window, not any child windows inside of
it. You can use ChildWindowFromPoint() after calling WindowFromPoint(),
however.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.