Article View: borland.public.cppbuilder.nativeapi
Article #8384Re: Get text from Treeview & get window events
From: Segal
Date: Wed, 27 Oct 2004 20:40
Date: Wed, 27 Oct 2004 20:40
49 lines
3503 bytes
3503 bytes
Remy Lebeau (TeamB) wrote: > "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. Thank you very much for replying. I have never done this before, are there any examples? I've never done a dll before, wel, not one that communicated with an app I'm writting in BCB. I've been programmign C++ quite a bit, I'm very familiar with it, just never did much with dll and hooks like this, if you could provide some good examples or so, it would really help. >> 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'm not getting how I would get notified? Would I use some sort of call back function, to make it "event driven" ? >> 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. So I would have to poll it ever so often?
Technical Details
Message-ID:
<4180082f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<417fdf69$1@newsgroups.borland.com> <417fe585$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: "Segal" <none@none.spam.sucks.balls> Newsgroups: borland.public.cppbuilder.nativeapi References: <417fdf69$1@newsgroups.borland.com> <417fe585$1@newsgroups.borland.com> Subject: Re: Get text from Treeview & get window events Date: Wed, 27 Oct 2004 13:40:21 -0700 Lines: 51 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: 66.234.219.101 Message-ID: <4180082f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1098909743 66.234.219.101 (27 Oct 2004 13:42:23 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail