|
Nope, it's got a .cpp extension.
What's confusing me is that it seems to have no problem with the try block, although that may be due to the way the compiler is parsing the file.
|
|
|
|
|
It shouldn't be causing any error. Can you provide more info about where this piece of code is inserted?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Well, the orginal problem was from some code in the depths of MS's STL code, namely INCLUDE\xstring....
template<class _E,
class _Tr = char_traits<_E>,
class _A = allocator<_E> >
class basic_string {
...
...
...
_TRY_BEGIN
_S = allocator.allocate(_Ns + 2, (void *)0);
_CATCH_ALL
_Ns = _N;
_S = allocator.allocate(_Ns + 2, (void *)0);
_CATCH_END
with the following defines in INCLUDE\xstddef
#define _TRY_BEGIN try {
#define _CATCH(x) } catch (x) {
#define _CATCH_ALL } catch (...) {
#define _CATCH_END }
The errors I get are:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(527) : error C2059: syntax error : 'catch'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(521) : while compiling class-template member function 'void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int)'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(527) : error C2143: syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(521) : while compiling class-template member function 'void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int)'
I haven't had any problems with the STL before, but the project I'm trying to compile is a .dll for use by DirectShow, so it has some wierd project settings. I can't really explain what is wierd about them, as I don't understand them too well (the project is based on a sample from the DirectX documentation).
Does that help? Any more info you need?
Pete
|
|
|
|
|
Does that help? Any more info you need?
Could you please post the beginning of the .cpp where this is included (implicitly or explicitly)?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
#include "CenFilter.h"
#include < initguid.h >
#include "../vss/fdckid.h"
#include "CenFilter.h"
#include <initguid.h>
#include "../vss/fdckid.h"
#include "../vss/array.h"
#pragma warning(disable: 4800)
IPin * GetInPin( IBaseFilter * pFilter, int PinNum );
IPin * GetOutPin( IBaseFilter * pFilter, int PinNum );
#pragma once
#include < streams.h >
#include "../../vss/ImageProcessing.h"
#ifdef _DEBUG
#include < stdio.h >
char static gDbgStr[200];
#endif
Is this what you need?
|
|
|
|
|
The code didn't seem to help much... I'm far from sure about what follows, but it's worth giving a try. Go to Project->Settings, C/C++ tab, Code Generation, enable C++ exceptions.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Already tried that
|
|
|
|
|
I just noticed something. In the project settings command line options there is the following:
/D try=__try /D except=__except /D leave=__leave /D finally=__finally...
which I'm guessing redefines try to __try, etc.
Looking in MSDN, it seems that __try is a MS-specific extension for C. It also says:
"Note Structured exception handling works with Win32 for both C and C++ source files. However, it is not specifically designed for C++. You can ensure that your code is more portable by using C++ exception handling. Also, C++ exception handling is more flexible, in that it can handle exceptions of any type. For C++ programs, it is recommended that you use the new C++ exception-handling mechanism (try, catch, and throw statements). "
Maybe I'll try removing those lines in the project settings and see what happens...
|
|
|
|
|
Ummm... think you've got something now. Please tell us the result. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hurray!
Yep, that (eventually) fixed the problems.
Thanks for the help Joaquin,
Pete
|
|
|
|
|
Thanks for the help Joaquin
I didn't help much this time, it was all your job.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
well, thanks for the moral support then
|
|
|
|
|
Hello,
I am trying to pull text from inside a edit box on another application.. Here is what I have tried, this only pulls the windows title bar text.. any ideas on how i can pull text from with in a edit box on another app?
CWnd* cWnd;
POINT pt;
::GetCursorPos(&pt);
cWnd = WindowFromPoint(pt);
CString strBuf;
cWnd->GetWindowText(strBuf);
MessageBox(strBuf);
Thanks
Rob
|
|
|
|
|
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
|
|
|
|