|
I guess you can call ChildWindowFromPoint on the cWnd retrieved, sort of like this (warning: didn't compile it):
CWnd* cWnd;
POINT pt;
::GetCursorPos(&pt);
cWnd = WindowFromPoint(pt);
cWnd->ScreenToClient(&pt);
CWnd* cChildWnd = cWnd->ChildWindowFromPoint(pt);
CString strBuf;
cChildWnd->GetWindowText(strBuf);
MessageBox(strBuf);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I think the better way is to use SendMessage and OnCopyData.
1. First you search your target window handle.
2. You send a WM_COPYDATA to target window.
3. Write in your target app a function to handlw WM_COPYDATA
Code:
char szWindowName[60];
// "Target App" is the target app main window caption
CString szTargetWindowName = "Target App";
int nFound;
int nLength = strlen(szTargetWindowName);
HWND hSearchHandle;
for(hSearchHandle=::GetWindow(::GetDesktopWindow(), GW_CHILD);hSearchHandle; hSearchHandle = ::GetWindow(hSearchHandle, GW_HWNDNEXT))
{
::GetWindowText(hSearchHandle, szWindowName, 58);
szWindowName[nLength] = '\0';
nFound = lstrcmpi(szWindowName, szTargetWindowName);
if(nFound == 0)
{
CWnd pCwnd;
COPYDATASTRUCT cds;
char myStr[60];
strcpy(myStr,"Lets go.");
cds.dwData = 0;
cds.lpData = myStr;
cds.cbData = sizeof(myStr);
LONG lResult;
lResult = ::SendMessage(hSearchHandle, WM_COPYDATA,(WPARAM)&pCwnd.m_hWnd, (LPARAM)(COPYDATASTRUCT*)&cds);
}
}
-----------------------------------------
Now in your target app:
BOOL CAppADlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
MessageBox((char *)pCopyDataStruct->lpData);
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
Try it.
|
|
|
|
|
The target app is not mine (It's commercial software and I don't have the source code)..
Basicly what I am trying to do is pull text from the Rich edit control on Yahoo! Messenger (The chat window. When you are talking to someone) and store the whole msg in a string.
|
|
|
|
|
GetWindowText will not retrieve the text in an edit control in another application (thread?). GetWindowText retrieves the caption from the window's internal data. Even with a lot of text, edit controls always have an empty string as its caption.
The workaround is to send the edit control a WM_GETTEXT message (preferably using SendMessageTimeout) to retrieve the text.
Peter O.
|
|
|
|
|
You can't use GetWindowText() to get the text from an edit control. At least that's what it says in MSDN. You will have to use SendMessage() to copy data like the guy above me said.
|
|
|
|
|
Why would you want to declare a function as "static" when that function is NOT part of a class?
In other words:
static void MyFunction(int blah, string blahblah)
{
}
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
static in that situation will limit the function scope to that module (source file). so, every module could have a MyFunction fn, and the linker wouldn't complain.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
This code is a freakin nightmare of complexity and work-arounds that were implemented 8 years ago when the product was a dos app.
There's no reason I can think of to make a generic function (like these appear to be) static.
I hate this project. This is a CE app (we're still slogging along with CE 2.1) with no user interface, and the guy who did it made it so we can't just upgrade to the latest version of CE. What's worse, there are virtually no comments in the code, no design or spec documentation, and the guys that originally developed the thing are long gone.
We want to upgrade to a newer version of CE, but we don't have the expertise (or the time), and the boss won't let us do it unless we find a customer to pay for it. We had an outside consultant company give us an estimate on doing the conversion for us, and they want $150,000.
We're screwed.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
I think this is to prevent it from being used in other files
or conflicting with other functions.
Without the static keyword, the function could be
used in another source file by simply declaring it.
|
|
|
|
|
To add to the other guys' (absolutely correct) answers: the C++ standard deprecates this use of static in favor of placing functions inside the so-called unnamed namespace:
namespace {
void MyFunction(int blah, string blahblah)
{
}
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Interesting! Are there any good tutorials on namespaces you'd recommend?
Shog9
--
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer.
- Ryan Johnston, Don't die java!
|
|
|
|
|
Not only for the namespaces thing, but as a comprehensive book covering most of C++, Bruce Eckel's Thinking in C++ is a good choice. Plus, you can download it for free (legally!)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Plus, you can download it for free (legally!)
Oh! Cool!
Shog9
--
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer.
- Ryan Johnston, Don't die java!
|
|
|
|
|
Damn - you beat me to it !!! :P
On the topic of books, I wrote an article on namespaces for DDJ recently ( I have no idea when it will be published at this point ), and of all the books I read, the best coverage was 'Design and Evolution of C++', by you-know-who. Have you read it ? Is the 'Thinking in C++' coverage better, or similar ?
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Hi Chris,
On the topic of books, I wrote an article on namespaces for DDJ recently ( I have no idea when it will be published at this point ),...
Really? I'm eager to have a look at it!
I remember we were discussing the issue of namespaces as a way of implementing library versioning control. Have you included something on this?
...and of all the books I read, the best coverage was 'Design and Evolution of C++', by you-know-who. Have you read it ?
You bet I have. As a matter of fact, it is my bedside book right now. I prefer it to "The C++ Programing Language" because the latter is so uncomfortable to read in bed
Is the 'Thinking in C++' coverage better, or similar ?
I've had but a slight look at Eckel's book, so I'm not in a position to answer. I don't think it can say much more than DaEoC++, though.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
I remember we were discussing the issue of namespaces as a way of implementing library versioning control. Have you included something on this?
Absolutely. We covered the basics for completeness ( I cowrote it with a friend who works supporting the Forte compiler for Sun ), and focused mainly on anonymous namespaces and Koenig lookup ( and the fact that VC does not support the latter correctly ).
Joaquín M López Muñoz wrote:
I prefer it to "The C++ Programing Language" because the latter is so uncomfortable to read in bed
*grin* I'd says it's one of my favourites as well, and you're right, the small size makes it very portable.
Joaquín M López Muñoz wrote:
I don't think it can say much more than DaEoC++, though.
I would not have thought so - the coverage in there was awesome. I read the chapter every day for two weeks while I was writing the article.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Didn't know you wrote for DDJ --I volunteer as a betareader of your next article (if you need any). Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Didn't know you wrote for DDJ
Only just started. I still write for WDJ as well ( both on an article by article basis, nothing ongoing ). My current article will be on using XML in C#, I am writing a wrapper class for the XML stuff, and adding things like searching for nodes using regular expressions, as well as an app that allows you to edit XML and experiment with XSL. It's taking a while, but if it's under your aegis, I'd love your comments when I have a draft together.
I am also hoping to get some more standard C++ stuff happening for DDJ, but at this stage I am just waiting to hear what is happening to my image filtering and namespace articles which I have already submitted. I would most certainly like to get your comments on anything I write regarding C++, if it happens again.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
To add to what others have said, you can also use static to implement call backs in C++ classes. Although that means that you can have one instance of that object in your app at any one time (I think ). Take a look at "Creating a Simple Win32 Service in C++" in MSDN by Nigel Thompson, under the section header "Service Callback Functions".
Hope this helps
Dylan Kenneally
London, UK
|
|
|
|
|
When I use DAO, the system always occurs problem after the program end.
even the most baisc code will cause the problem:
#include <afxdao.h>
void main(){
CDaoDatabase db;
db.Open("db.mdb");
db.Close();
}
|
|
|
|
|
Hi, everyone!
Can you give me an example?
Cheers,
George
|
|
|
|
|
I think the method varies depending on the manufacturer...for Intel processors go to this site
ftp://download.intel.com/design/Xeon/applnots/24161821.pdf
It requires you to do inline assembler
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Hi,
It´s possible to make a normal application ( database driven, ... client, items... that stuff) With Visual C++, in a short time and with a proffessional look ?.
What I mean, is that if you take Borland C++, or VBasic, you have it ready quite fast, and with a good looking... and for example the database grid control that is shipped with VC++ is quite bad...
What do you think ?, greetings
Braulio
|
|
|
|
|
|
Hi,
Yes that control is superb, but you cannot connect that control to a database ( at least without taking you some weeks).
Braulio
|
|
|
|