🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8383

Re: Get text from Treeview & get window events

#8383
From: Remy Lebeau (TeamB)
Date: Wed, 27 Oct 2004 18:15
37 lines
2650 bytes
"Segal" <none@none.spam.sucks.balls> wrote in message
news:417fdf69$1@newsgroups.borland.com...

> Hello, I can get text (like a caption, or text from a textbox) from a
> given window of a program outside my program using WINAPI
> functions, but how does one get items in a Treeview in another
> program?

You need to first inject your program into the address space of the foreign
program.  Then you can query the TreeView using the normal TreeView API
messages.  This is because the messages use pointers, and you cannot pass
pointers across processes (not safely, anyway).  To inject your own code
into the foreign process, you will have to put your code into a DLL and then
use SetWindowsHookEx() to install a hook into the foreign process.  The hook
would be called in the context of the foreign process, and the hook would
run your code, so your code would run in the context of the foreign process.
Your hook could then send the data back to your main application via
WM_COPYDATA or other inter-process communications of your choosing.

> Also, this same program I'm trying to "hook" pops up little
> message boxes that I'm trying to intercept and get the text
> from, but I'm a little stuck on the interception part. Only way
> I can think of is running a loop or a timer with FindWindow
> seeing is one of these little windows is present?

A global hook via SetWindowsHookEx() would be more reliable.  Then you would
get notified when new windows are being created and displayed, and then can
test the new windows for your criteria and extract your text when needed.

> I want to be able to know when the foreign Treeview changes

The only way to do that is to subclass the TreeView window, but you cannot
subclass windows across processes.


Gambit
Technical Details
Message-ID: <417fe585$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <417fdf69$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,490c03cee5f5091
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <417fdf69$1@newsgroups.borland.com>
Subject: Re: Get text from Treeview & get window events
Date: Wed, 27 Oct 2004 11:15:22 -0700
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <417fe585$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1098900869 68.69.17.41 (27 Oct 2004 11:14:29 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail