|
Thanks, Superman.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Developing whatch dog on windows is very easy, all you need to create a named mutex from the process (program) needed to moniter, and from your moniter process, wait for that mutex handle to be closed. If it get closed than restart your program.
If you are a Linux user than crontab is your friend, use crontab instead of develop new watchdog so that you can spent time to find out why you program is crashing.
On windows you can use cronw.
Good Luck.
|
|
|
|
|
Hi,
Is anyone aware of a 'Task Manager Logging' App that can 'Capture and Record' most or all of the information viewable in Task Manager, sampled at regular intervals, in some form of Database. One of our clients experiences quite extensive memory leaks in Windows XP. We are confident that it is not our software, but it is a case of 'It only started happening after your stuff was installed' We would like to run something that takes a SnapShot, Starters say every fifteen minutes, and upon notifyable events, such as Process Starts or Stops.
Alternatively, is there a way to configure 'MS Windows Event Logging' to do the same.
I am just trying to figure out Why this customer gets 'Low virtual Memory' messages after two or three days running, and the system grinds to a Halt when that happens.
Regards,
Bram
Bram van Kampen
|
|
|
|
|
|
You could use Process Explorer[^].
Be sure to apply appropriate filters for logging because it does some extensive logging and could soon fill up your hard disk.
|
|
|
|
|
Thanks
This seems to fit the bill.
Regards,
Bram van Kampen
|
|
|
|
|
I am getting a syntax error on "namespace" declaring the following in MFC class variables. iostream is included in StdAfx header file.
namespace Test
{
int a;
int b;
}
Here is the partial error printout
error C2059: syntax error : 'namespace'
error C2334: unexpected token(s) preceding '{'; skipping apparent function body
Does that mean that in VC 6.0 I cannot use "namespace"?
Or did I missed something else?
Thanks for your time.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Does that mean that in VC 6.0 I cannot use "namespace"?
Probably.
Your code, exactly what you posted, compiles in VS 2005.
|
|
|
|
|
you're missing something else. namespaces work fine in VC6.
|
|
|
|
|
Addendum:
I build default MFC doc / view app and
I get same error with or without including either iostream or iostream.h.
To me that indictates that iostream does not define namespace.
Can it be defined somewhere else?
|
|
|
|
|
what do you mean by "define namespace" ?
|
|
|
|
|
If I get a syntax error the compiler does not recognize the "namespace" as valid syntax.
So it has to be defined to be vaild. Does not?
For example "if" is defined in similar way, but compiler flags "iff" as undeclared identifier.
I am just trying to find some reason why I am getting same syntax error with or without including iostream.
|
|
|
|
|
'namespace' and 'if' are C++ keywords. they're not defined in headers anywhere, they're built into the compiler itself.
|
|
|
|
|
You've probably left a semicolon, closing brace, closing parentheses or similar off the previous thing in the .h file.
Just out of interest, if you ever want to know if you can use a feature in a compiler just lop the code out and stick it in a .cpp file somewhere, making sure it's not dependent on any other code. In this case had you stuck:
namespace Test
{
int a;
int b;
} in a source file you'd have seen it compiles just fine in VC++6.0. As far as anything can be regarded as "compiling just fine" on that clunky piece of old rubbish.
|
|
|
|
|
Hello Ash,
here is a snippet of VC 6.0 generated CView header file with my add and resulting compliler errors:
class CTESTView : public CView
{
protected: // create from serialization only
CTESTView();
DECLARE_DYNCREATE(CTESTView)
// Attributes
public:
CTESTDoc* GetDocument();
using namespace test
{
int a;
int b;
}
// Operations
public:
.........
This is how iostram is included in STdAfx.h file:
#if !defined(AFX_STDAFX_H__D78D5AFB_F290_4B69_9F5A_23EC3FA245D9__INCLUDED_)
#define AFX_STDAFX_H__D78D5AFB_F290_4B69_9F5A_23EC3FA245D9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <iostream> <b>silly but the CodeProject edit box did not copy stuff in "arrow brackets" - but it is here - iostream
It did not show up in preview, go figure.
</b>
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
.....
And here is the full compiler output regardless of inclusion of iostream or not:
--------------------Configuration: TEST - Win32 Debug--------------------
Compiling...
TEST.cpp
z:\0\0 mdi\test\bamesapce\test\testview.h(23) : error C2059: syntax error : 'namespace'
z:\0\0 mdi\test\bamesapce\test\testview.h(24) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
TESTView.cpp
z:\0\0 mdi\test\bamesapce\test\testview.h(23) : error C2059: syntax error : 'namespace'
z:\0\0 mdi\test\bamesapce\test\testview.h(24) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
Generating Code...
Error executing cl.exe.
TEST.exe - 4 error(s), 0 warning(s)
I am ready to stop trying this, I really do not need it, but the stuff I am modyfying is using it. After succes of using
pure virtual class / function ( BTW many thanks for all you input on that ) I am just "looking for punishment".
Is it possible that I have some kinda of conflict with std namespace?
|
|
|
|
|
using namespace test
{
int a;
int b;
}
that's the problem.
it should be:
namespace test
{
int a;
int b;
};
and then, in your .cpp:
using namespace test; <--- fixed
|
|
|
|
|
Thanks Chris,
and this is the compiler output after your suggestion:
TEST.cpp
z:\0\0 mdi\test\bamesapce\test\testview.h(23) : error C2059: syntax error : 'namespace'
z:\0\0 mdi\test\bamesapce\test\testview.h(24) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
TESTDoc.cpp
TESTView.cpp
z:\0\0 mdi\test\bamesapce\test\testview.h(23) : error C2059: syntax error : 'namespace'
z:\0\0 mdi\test\bamesapce\test\testview.h(24) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
Z:\0\0 MDI\TEST\BAMESAPCE\TEST\TESTView.cpp(60) : error C2873: 'test' : symbol cannot be used in a using-declaration
Generating Code...
Error executing cl.exe.
TEST.exe - 5 error(s), 0 warning(s)
And here is what my ancient MSDN say about namespace:
namespace Declaration
C++ Specific —>
namespace [identifier] { namespace-body }
A namespace declaration identifies and assigns a name to a declarative region.
The identifier in a namespace declaration must be unique in the declarative region in which it is used. The identifier is the name of the namespace and is used to reference its members.
The declarative region of a namespace declaration is its namespace-body.
END C++ Specific
Notice - no semicolon.
And if it is a keyword it must not be in my VC6.0 Sp6 stuff.
I give up.
|
|
|
|
|
here is the complete source of a test program demonstrating the use of namespaces in VC6:
namespace foo
{
class testing
{
public:
testing()
{
i = 10;
}
int i;
};
};
using namespace foo;
int main(int argc, char* argv[])
{
testing t();
return 0;
}
|
|
|
|
|
Hi Chris - your line:
testing t(); doesn't actually create a new object. It's a prototype for a function that takes no parameters and returns a testing object.
It's a real bugger with C++ and bites loads of people. It's also the reason that the latest C++ standard introduced uniform initialisation (using braces where we've used parenthesis up to now).
|
|
|
|
|
ok. but that's not the point here.
|
|
|
|
|
Ah ha! Your problem is nesting a namespace within a class. You can't do that. This code gives the same error you got:
class A
{
namespace B
{
}
}; If you want something similar to a namespace nested within a class use another class:
class A
{
class B
{
};
}; It's probably got the effect you want.
|
|
|
|
|
Ash,
you are "the man"! ( Or a woman, I cannot tell from your name)
What has happended, as many times before,lazy me blindly copied ton of #define(s) wiht my new class and there was "use namespace std" in the mess.
I broke my code and had to go back a bit and without the additional defines the namespace stoped giving me syntax error.
One down, thanks to all of you guys persistence.
Appreciate that very much.
Now if I can find someone who knows capAVI and its use in OpenCV I'll be a happy camper.
Thanks Vaclav
|
|
|
|
|
Hi,
I am looking for the best approach to process KeyStroked <ENTER> <F7> <F8>
My code is MFC using Message using message mapping macros
I have a number of questions
1) what would the message be for a Keystrokes
2) is the message directed to the Dialog Box that contains the rich edit or is better to have the rich edit process to message
3) if I wrap the CDialog with a CWinThread
I can use the ::Run command to process the key strokes
<pre lang='cpp'> int CWinthread::Run()
{ ASSERT_VALID(this);
MSG m_msgCur;
for tracking the idle time state
if (!flags.is_connected)
return TRUE;
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
// acquire and dispatch messages until a WM_QUIT message is received.
for (;;)
{ phase1: // check to see if we can do idle work
while (bIdle && !::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{ // call OnIdle while in bIdle state
if (!OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
} // phase2: pump messages while available
do { // pump message, but quit on WM_QUIT
if (!PumpMessage())
return ExitInstance();
// reset "no idle" state after pumping "normal" message
if (IsIdleMessage(&m_msgCur)) {
bIdle = TRUE;
lIdleCount = 0;}
} while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE));
}
ASSERT(FALSE); // not reachable
} </pre>
thanks for youe help
|
|
|
|
|
The messages for keystrokes are WM_KEYDOWN and WM_KEYUP .
These are directed to the parent dialog containing the control.
To have the message directed to the control in MFC, you have to create a class derived from CRichEditCtrl and then subclass the control from the InitDialog function of the dialog class using the SubclassDlgItem[^] method.
|
|
|
|
|
Superman:
I respectfully disagree.
quote: "The messages for keystrokes are WM_KEYDOWN and WM_KEYUP
These are directed to the parent dialog containing the control."
Unless dialog does not contain any controls, dialog window never gets focus, hence WN_KEYDOWN and WM_KEYUP messages are not sent to a dialog.
quote: "and then subclass the control from the InitDialog function of the dialog class using the SubclassDlgItem method."
It is possible to use SubclassDlgItem or SubclassWindow but it would be much easier to let the wizard do subclassing, by simply add variable of the CRichEditCtrl and later replace it with the derived class type.
ForNow:
Depending what is exactly you are trying to achieve, I think the best way to handle special keys is creating accelerators and add handlers to a CRichEditCtrl derived class.
JohnCz
|
|
|
|