|
Hi,
// Get the current time (start time).
DWORD dwStartTime = GetTickCount();
// The stuff here takes some time
// Subtract start time from current time to get duration.
DWORD dwElapsedTime = GetTickCount() - dwStartTime;
/////////////////////
Also see the APIs:
GetThreadTimes
GetProcessTimes
--
======
Arman
|
|
|
|
|
Are you sure it will give the time difference less than second?
Thanks
|
|
|
|
|
for higher accuracy than this method, look up high resolution performance counters here
link: MSDN - Timers[^]
|
|
|
|
|
Yes it does. It gives the time difference in milliseconds.
--
======
Arman
|
|
|
|
|
I am using Visual C++ 6.0 MFC with a single document application. I can create a graphic of a wafer map showing the failures by bin number. There are 32 different bin numbers. I can bring up a dialog that alows me to select the bin numbers to display and then print that current view. But I need to print the wafer map for each bin, which means that I have to open the dialog box and check bin 1 and then print, then open the dialog box and check bin 2 and print and so on 32 times. What I want to do is simply tell the application to print by bin and have 32 maps printed, one for each bin number. How would I go about doing this?
Buck
|
|
|
|
|
I have this code that doesn't work. I try to convert an image to the frequency domain using dct and then back
numx: width in bytes of the image
numy: height
ppixel[]: the pixels of the image. I use them as a 1-D array.
The code goes like this:
<code>
/********************************Starting the DCT transform**/
double pi = 3.14159265359;
double sum=0;
double *pdct=new double[numx*numy]; //the dct coefficients
for (int xx=0;xx<numx*numy;xx++)
{
sum+=ppixel[xx];
}
pdct[0]=sqrt(1/(numx*numy))*sum; //dct for u=0 (DC)
sum=0; //resetting
for (int u=1;u<numx*numy;u++)
{
for (int x=0;x<numx*numy;x++)
{
sum+=ppixel[x]*cos((pi*(2*x+1)*u)/(2*numx*numy));
}
pdct[u]=sqrt(2/(numx*numy))*sum; //the dct for u!=0 (AC)
}
</code>
My idct code is:
<code>
/********************************Creating the IDCT transform**/
sum=0; //resetting
for (int x=0;x<numx*numy;x++
{
for (int u=1;u<numx*numy;u++)
{
sum+=sqrt(2/(numx*numy))*pdct[u]*cos((pi*(2*x+1)*u)/(2*numx*numy));
}
ppixel[x]=sqrt(1/(numx*numy))*pdct[0]+sum; //the first is for u=0 and the sum for u!=0
}
</code>
Is there somwthing wrong that I don't see? Can anyone help me?
Thanks..
|
|
|
|
|
I've constructed a propertysheet with a working ON_UPDATE_COMMAND_UI system.
I've constructed a dialogbar with a working ON_UPDATE_COMMAND_UI system.
I've constructed a dialogbar with an embedded propertysheet.
Now how do I construct a dialogbar with an embedded propertysheet _AND_ still have ON_UPDATE_COMMAND_UI working in the propertysheet?
CMyDialogbar has a CMyPropertySheet member which assume the position of a placeholder control in the dialogbar. The problem seems to be that the idle message does not cascade on from CMyDialogbar into the CMyPropertySheet. Any ideas?
Regards,
David.
|
|
|
|
|
>The problem seems to be that the idle message does not cascade on from CMyDialogbar into the CMyPropertySheet. Any ideas?
Try handling it yourself.
afx_msg LRESULT OnKickIdle(WPARAM,LPARAM);
...
ON_MESSAGE(WM_KICKIDLE,OnKickIdle)
...
LRESULT CMyDialog::OnKickIdle(WPARAM wp, LPARAM lCount)
{
UpdateDialogControls(this, TRUE); // the dialog
// try
pMyPropertySheet->UpdateDialogControls(this, TRUE);
// or
UpdateDialogControls(pMyPropertySheet, TRUE);
// or
pMyPropertySheet->UpdateDialogControls(pMyPropertySheet, TRUE);
// or
::SendMessage(pMyPropertySheet->GetSafeHandle(), WM_KICKIDLE, wp, lp);
return 0;
}
One might work (I am not sure if this is the right way to do this or if it still works - WM_KICKIDLE is/was internal MFC message). Try it...
There might be an extra include for the WM_KICKIDLE that is needed...
Good luck!
H.
|
|
|
|
|
I need some help. Here it the whole code snippet:
#include "stdafx.h"
template<typename T>
int IndirectFunction(int * pData)
{
return 0;
}
//also tried
//int __cdecl IndirectFunction(int * pData)
//{...}
typedef int (*ONEPARAMFUNCTION)(void* param);
//also tried
//typedef int (__cdecl *ONEPARAMFUNCTION)(void* param);
int main()
{
// <<<<<<<<<
//error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'ONEPARAMFUNCTION'
ONEPARAMFUNCTION t = (ONEPARAMFUNCTION) &IndirectFunction<int>;
// >>>>>>>>>
return 0;
}
How can I make it work ??
I tried googling a little - C2440 seems to be pretty "popular" but I didn't find anything that could help me.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/C2440.asp also didn't help
Seems it happens becouse of the template, if I remove it compiles ok (using only - int IndirectFunction(int * pData) without the template<>).
If I replace:
int IndirectFunction(int * pData)
with
int IndirectFunction(void * pData)
it compiles ok.
If I use templates and int* as parameter I get the error. Help!
-- modified at 14:22 Friday 21st October, 2005
|
|
|
|
|
try:
int (*ONEPARAMFUNCITON)(int*) = IndirectFunction<int>;
then:
int x(666);
cout << ONEPARAMFUNCITON(&x) << endl;
should work!
-- modified at 15:11 Friday 21st October, 2005
|
|
|
|
|
And it works perfectly!
I would never think of this on my own - it looks wierd, but it works!!
Thank you so much!
H.
|
|
|
|
|
This is normal when using templates.
The compiler only creates functions that are needed in your program.
Son you can't create a function pointer to such function until it exists.
When you first write funtion<int>(666); the compiler creates
such function. Later you can get a function pointer from it.
It seems odd but this is the way it needs to be done, with some sort of dummy call to the function
Hope this explains the wierd behaveior
codito ergo sum
|
|
|
|
|
| Quote:
>When you first write funtion<int>(666); the compiler creates
such function. Later you can get a function pointer from it.</blockquote>
But that isn't what is happening (atleast I don't see it) - I first take the pointer and then call the function. And it works if I take the pointer to a function that has the exact signature, that is the int* parameter. The problems are created when I try to get a pointer to function and cast it to a function that takes a void* in the same command/line.
template<typename T>
int IndirectFunction(int * pData)
{
return 0;
}
typedef int (*ONEPARAMFUNCTION_PVOID)(void* param);
typedef int (*ONEPARAMFUNCTION_PINT)(int* param);
int main()
{
ONEPARAMFUNCTION_PINT pF0 = &IndirectFunction<int>; // ok!!
ONEPARAMFUNCTION_PINT pF = IndirectFunction<int>; // ok!!
ONEPARAMFUNCTION_PVOID pF2 = (ONEPARAMFUNCTION_PVOID)IndirectFunction<int>; // error!!
ONEPARAMFUNCTION_PVOID pF3 = (ONEPARAMFUNCTION_PVOID)pF; // ok!!
ONEPARAMFUNCTION_PVOID pF4 = (ONEPARAMFUNCTION_PVOID)(ONEPARAMFUNCTION_PINT)IndirectFunction<int>; // ok!!
int a =5;
pF(&a);
pF2(&a);
pF3(&a);
pF(&a);
return 0;
}
The wierd part is that this works:
ONEPARAMFUNCTION_PVOID pF4 = (ONEPARAMFUNCTION_PVOID)(ONEPARAMFUNCTION_PINT)IndirectFunction<int>; // ok!!
But this won't work:
ONEPARAMFUNCTION_PVOID pF2 = (ONEPARAMFUNCTION_PVOID)IndirectFunction<int>; // error!!
But isn't this practicaly the same?
IndirectFunction<int> should have the same signature as the ONEPARAMFUNCTION_PINT so the cast shouldn't be needed and the second example should be the same as the first one (I even tried forcing the same calling convention, but MSVC7 still thinks that ONEPARAMFUNCTION_PINT and IndirectFunction<int> have different signatures and requires the cast to ONEPARAMFUNCTION_PINT first) ???
|
|
|
|
|
I have taken your code and everything compiles without errors.
But guess what , I have used MSVS 2005 (MS VC8) so this is certainly a bug in the VC7 compiler.
So your code is right but your compiler (I use the same at work ) missed the pedals, happens to the best of us
codito ergo sum
|
|
|
|
|
BadKarma wrote: I have used MSVS 2005 (MS VC8) so this is certainly a bug in the VC7 compiler.
VC8 is probaby the only compiler I haven't tried
VC7.1 - same error
VC6 - more errors, oh well
GCC3.2 - same error
Thanks for your help
|
|
|
|
|
In one of my classes (on programming in Scheme) my professor said that C++ is an "unsafe language". Could anyone help explain what that really means? I tried googling it, without much luck. Thanks.
-Ken Maz
|
|
|
|
|
Try googling unsafe for C# and you'll se what is considered to be unsafe.
Some of the "unsafe" things are:
-variables don't have to be initialised before use
-you can cast pretty much anything to anything else
-pointers are generaly unsafe
-normal arrays are not bounds checked and can owerflow
-a milion more things...
|
|
|
|
|
Thanks for the response.
-Ken Maz
|
|
|
|
|
Yeah, basically, C++ allows you to do a lot of things that could potentially be dangerous, like accessing out of the bounds of an array, and leaves it up to the programmer to make sure the program is doing what he wants it to do.
Danny
The stupidity of others amazes me!
|
|
|
|
|
Ken Mazaika wrote: In one of my classes (on programming in Scheme) my professor said that C++ is an "unsafe language".
Make sure you fully understand in what context he was talking. Otherwise, you could treat that as a blanket statement and come away with a completely misguided view of a very good language.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
Try using RegisterHotKey for receiving Win+D or a global hook.
I don't know how you could respond to that specific button, but quick launch bar is fully customisable and you could add a shorcut to an application that would show your application (or even a shorcut to the application itself).
-- modified at 13:49 Friday 21st October, 2005
|
|
|
|
|
Or one other idea, don't do it. The user of windows expects that clicking the desktop icon on using WINDOWS + D keys to hide ALL windows, including your application. To play with Windows expected functionality can be kind of cheating the user.
Danny
The stupidity of others amazes me!
|
|
|
|
|
bugDanny wrote: To play with Windows expected functionality can be kind of cheating the user.
I agree. Users expect their Windows applications to have a common intuitiveness. To alter that could have negative repercussions.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi left a message about subclassing in Visual Studio 2003.
I got a few replies and some were helpful, but some wernt related to VS 2003.
Subclassing in VS6 is pretty easy because of the class wizards ability to bind the new class to the control on the dialog or window.
However in VS 2003 it doesnt have that!
Here is the url for the previous post ->
click here
Thanks Tom
|
|
|
|