|
you are right Giogi,
SetTimer is some Machine Dependent! it based on cpu,load on machine etc..
so as Mr. Gary has mentioned you can go for
BOOL QueryPerformanceCounter( LARGE_INTEGER *lpPerformanceCount
);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'll do it Alok ,
thanks
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
I am attempting to adopt only new programming style so I have a question and would like opinions on it...
For debugging in console applications I have seen the following used quit often:
#define DEBUG 1
#define debug if (DEBUG) cout
Then to output debug messages I would do: debug << "Program initiating" << endl;
and so forth...
After which before release DEBUG is set to 0, is this still the modern way to go about doing this?
"Your KungFu is not strong enough"
|
|
|
|
|
I believe _DEBUG is defined when you do a debug build so this would allow you to control your trace statements between debug and release builds.
Elaine
The tigress is here
|
|
|
|
|
Hello,
This depends on your needs. If you're writing a time critical application, you may want to remove the debug messages from your application. If you're writing a service oriented application, you may want to write debug messages to a file or whatever.
I've a general debug (template) library which writes the debug messages wherever I want. I even don't have to write preprocessor statements in my code. I think that something similar is the way to go these days. simple tracing messages won't do anymore. The main reason for this is that you also want error information from release builds.
I think that you should experiment with different ways of saving debug output and write a simple conveniant library that fits your needs.
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Dear all
In VC++ i'm able to initialise the structure member for int. But, for the below piece of code i'm getting compile time error.
struct one
{
CString name;
}two={"doubt"};
Please kindly suggest me a better way to solve this problem.
|
|
|
|
|
S.R.Sasi Kumar wrote: i'm getting compile time error.
What error? Is it C2552: 'two' : non-aggregates cannot be initialized with initializer list?
Only aggregate types can be initialized with an initializer list. Aggregate types are arrays, classes or structures that have:
- no constructors
- no private or protected members
- no base classes
- no virtual functions
- no non-aggregate members
CString has constructors and protected members so it is a non-aggregate type. As struct one has a non-aggregate member, it is also a non-aggregate, so you get error C2552.
struct one
{
CString name;
} two;
two.name = "doubt";
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
One approach to solving this problem is to have a second struct that contains your initializers:
struct one {
CString name;
} two;
struct one_init {
LPCTSTR name;
} two_init = { "doubt" };
two.name = two_init.name; Of course, this makes a lot more sense when you are initializing an array, and the structure members are more complex.
Software Zen: delete this;
|
|
|
|
|
Dear sir
I followed the same syntax(both the option) and i'm getting the following error when i try to initialize the structure in VC++
struct one
{
CString name;
} two;
two.name="doubt";
and also
struct one
{
CString name;
} two;
struct one_init
{
LPCTSTR name;
} two_init = { "doubt" };
two.name = two_init.name;
1.syntax error : missing ';' before '.'
2.missing storage-class or type specifiers
3.two' : redefinition; different basic types
Please suggest me to rectify the mistake.
|
|
|
|
|
Dear friends,
I have declared a structure variable in common.cpp and i want to use the structure members in one.cpp as well as two.cpp. When i include the common.h in those two files, i am getting the "LINKER ERROR" saying
"struct COMMSETTINGS commparam" (?commparam@@3UCOMMSETTINGS@@A) already defined in DLMSView.obj
Please help me in solving this problem
|
|
|
|
|
common.h:
struct COMMSETTINGS {
};
extern COMMSETTINGS commparam; common.cpp:
#include "Common.h"
COMMSETTINGS commparam; one.cpp and two.cpp:
#include "Common.h" Note the extern keyword used in common.h. This keyword, used in the declaration, tells the compiler/linker that the definition is found elsewhere. In this case, the definition is in common.cpp .
Software Zen: delete this;
|
|
|
|
|
Hi all:
I have a problem when I try to divide two floating point number to get a reasonable integer result. For example 1.0000 / 0.2000, this gives me 4 but not 5. Does anybody have any good idea to solve this problem please???
Many thanks
Asura
|
|
|
|
|
how do you do this ?
did you try using ::floor() and ::ceil() too ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
1.0000 / 0.2000 should give you 5. so the values must be a little different than you think.
In any case, one old trick is simply to add 0.5f to the result of the division. When you cast the result to an int if the original result was x.5 or greater the result will be x + 1 otherwise it will be x.
|
|
|
|
|
For negative numbers, you need to subtract 0.5f.
-0.7 + 0.5 = -0.2 => 0.0
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Stan has it right. The issue is that when converting from a real value to an int the compiler truncates the result. Here's something you can try :
int NearestInt( double value )
{
return (int)( value + 0.5 );
}
int NearestInt( float value )
{
return (int)( value + 0.5f );
}
-- modified at 13:37 Saturday 19th November, 2005
|
|
|
|
|
Testing VC++ code for pointer underflow/overflow for data type char *.
knarasimharao
|
|
|
|
|
I suppose you can check the index into the string, and the size of the string, which was allocated, so that the index should be less than the size, and always greater or equal to zero.
You can use:
AfxIsValidString(...)<br />
AfxIsValidAddress(...)
to check that the address is readable/writable.
this is this.
|
|
|
|
|
don't make the confusion : char* is not always a string !!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
I want to add my own printer dialog setupt in the list of supported printer drivers , sort of virtual printer driver not doing actually printing , or simply i want to extend office printer dialog
|
|
|
|
|
Hi all,
I wanna write a program that can monitor and discover any change of file in windows sytem and notify the change to user. where should i begin and what should i read ?
Thanks,
ken
|
|
|
|
|
I think ReadDirectoryChangesW(...) should do.
It can watch a directory for changes.
There are a few resources (articles) here on CP that implement this function.
this is this.
|
|
|
|
|
|
Hi.I'm seeking for help on my recent project.Actually, i'm developing a program that embeds several network analysis tools into single program.That is, once the user clicks on button "Tool 1", the .exe file of the tool will be called and it will run the tool.The problem now is, i don't know how to link the button with the corresponding file.Please help me.
-- modified at 3:03 Saturday 19th November, 2005
|
|
|
|