|
I'm not sure why you are still discussing timers. Roger recommendeded repeatedly that you use
the performance counter.
Periodic timers aren't much help to calculate elapsed time. You need a reference time that you
can check at the start, check at the finish, and calculate the delta. That's what the performance
counter is for.
Even a multimedia timer at true 1ms resolution isn't accurate enough IMO (unless the function(s)
you are timing always take many seconds. 1ms is a long time.
Mark
|
|
|
|
|
Hi Mark,
What makes me confused is, I think multimedia timer is a periodic timer. So, how could multimedia timer be used for calculating elapsed time?
regards,
George
|
|
|
|
|
the performance counter is NOT a periodic timer. It's like get tick count with much better
resolution. On my 3.2GHz box it's incremented on every clock tick (3.2GHz frequency).
You could use GetTickCount if 10ms-55ms accuracy is good enough.
Get the count, run the function, get the count again. Subtract and you have your elapsed time.
Factor in the frequency to convert to seconds, milliseconds, nanoseconds, whatever.
Mark
|
|
|
|
|
Thanks Mark!
If user changed the system time during my application runs, will the tick counter be impacted?
(I am wondering whether the counter values are dependent on system time.)
regards,
George
|
|
|
|
|
Where GetTickCount() and the performance counter get their time from varies depending on the
hardware but neither are affected to the system time.
There's a white paper from microsoft about certain motherboards with a bug that affects the
performance counter (it jumps ahead 2 or 4 seconds occasionally) but I can't find it at the
moment. Athlon boards I think...
Mark
|
|
|
|
|
Good point! Thanks Mark!
regards,
George
|
|
|
|
|
Hi...
I need some method to check wether a printer conected to my device or not..I am using GetDefault() function,and also using DeleteDC to delete device context..but it is showing some memory leak with Epson printer.can i use some other function to check for the connected printer.
birajendu
CyberG India
Delhi
India
|
|
|
|
|
|
|
I have drawn sqaure n circle in VC++ . and the requirement is wen i press space bar the colour of the square n circle shud change.
|
|
|
|
|
|
I have drawn sqaure n circle in VC++ . and the requirement is wen i press space bar the colour of the square n circle shud change.
|
|
|
|
|
Add an event handler for keys .. e.g. WM_KEYDOWN or WM_KEYUP whichever you require..
In the event handler check the keycode provide to be of space bar.. set the colors to whatever you want .. i know the answer is a little vague but so was the question :P.. Look into the MSDN for WM_KEYDOWN or WM_KEYUP for specific handling!
|
|
|
|
|
thanks for the help . i know that the event is WM_KEYDOWN but main thing is wat code shud i write to change the colour . i know the key events. please let me knw if u knw this
|
|
|
|
|
cshah2 wrote: but main thing is wat code shud i write to change the colour
Set the new color in your respective member variable and trigger a redraw
You did draw them before, so erase the screen, redraw, but take the color from the color-member-variable mentioned above).
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
hi,
i want to know which SP is installed on my machine.
I hav evn implemented that using wmi. It even works
but i want to know, if using wmi is a better option or chking registry is a better option.
If I have a list of the exes KBXXXX then can I chk registry as well ?
I want to know if wmi and chking these registry entries is giving me the same result - that is to let me know that SP2(or whichevr) is installed.
Please help.
|
|
|
|
|
Call GetVersionEx() and pass an OSVERSIONINFOEX struct. You can then check the wServicePackMajor and wServicePackMinor members of the struct.
|
|
|
|
|
Hi all,
I am having a memory leak.
// senario
//To include CGTDObjectShape class
#include "GTDObjectShape.h"
in .h Class
class CGTDSwitchBasic : public CObject
{
public :
CGTDObjectShape *mC_ONShape; // CGTDObjectShape class
CGTDObjectShape *mC_OFFShape; // CGTDObjectShape class
};
in .CPP Class
CGTDSwitchBasic::CGTDSwitchBasic(UINT pui_SwitchDrawObjID)
{
// Create a new Instace of the Object Shape.
mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0);
mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1);
}
--> Memory Leak after Closing the Application
GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long.
//===========================================================================
Please help me out.
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: // Create a new Instace of the Object Shape.
mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0);
mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1);
Where you have deleted this memory ?
|
|
|
|
|
hi prasad,
//Code Snippet.
//==================================================================
CGTDSwitchBasic::~CGTDSwitchBasic()
{
if(mC_ONShape){
delete mC_ONShape; //Deleted Here
}
if(mC_OFFShape){
delete mC_OFFShape; //Delete Here
}
}
//==================================================================
please give your suggestions.
Uday kiran
|
|
|
|
|
How you are using CGTDSwitchBasic object? If its pointer, probably its not deleted , which inturn causing this leak. Probably , providing more code should do.
uday kiran janaswamy wrote: if(mC_ONShape){
delete mC_ONShape; //Deleted Here
}
There is no harm calling delete on NULL pointer. You can avoid if statement here. Just set pointer to NULL after deleting it.
|
|
|
|
|
uday kiran janaswamy wrote: client block at 0x0D732450
There is an article in MSDN with the following heading
"Detecting and Isolating Memory Leaks Using Microsoft Visual C++"
This artcile will explain to you what are client blocks and normal blocks and how to set breakpoints on allocations.
|
|
|
|
|
uday kiran janaswamy wrote: GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long.
What is line 70 in your cpp ?
|
|
|
|
|
Hi Prasad,
The Line 70 is
mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); //Line 70.
Please help me out prasad.
Uday kiran
|
|
|
|
|
Does d'tor of CGTDSwitchBasic is getting called ? If CGTDSwitchBasic is created on heap, are you calling delete on it ?
Does c'tor of class CGTDObjectShape does some memory allocation , which is not getting deleted ?
|
|
|
|