|
|
I receive event 1,
I would like to set a timer to the millisecond
When i receive event 2,
I would like to stop that timer.
Anyone know what i should use?
Also, if i decide to get the current time to the millisecond after the 1st event, then do the same for the second event.
Then i can subtract the two and get the difference in time
Anyone know how to do that as well?
|
|
|
|
|
SetTimer() would send you WM_Timer messages, but handling this with a resolution of (less than) a millisecond is asking a bit much.
If you can afford to rely on DirectX, timeSetEvent() would be the way to go.
It provides you with the possibility to be called with a much higher accuracy.
Measuring even shorter durations is easy:
You ::QueryPerformanceCounter() on event1.
You ::QueryPerformanceCounter() on event2.
The difference is your duration between the events.
Be sure to ask ::QueryPerformanceFrequency() about if and with which frequencies the timer runs.
"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.
|
|
|
|
|
This question has been asked and answered many times. What is it that you are not understanding?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
This previous response was the only response that gave me something to try to the nearest millisecond. Other responses, simply said that this cannot be done to accuracy with a windows OS. I have looked at a few other API calls but they all give time to the nearest second..
This current response gave me (QueryPerformanceCounter) to try that i had never tried to achieve millisecond time...
|
|
|
|
|
hi, can somebody help me to determine the source code for chain code?
|
|
|
|
|
what is chain code ?
what is it supposed to do ?
|
|
|
|
|
|
Hi there,
I receive some data as packets in XML format and I need to verify thier type for further implementation, and I can understand what kind of data I am dealing with as I need to send the data to different palces through socket (for example: if the data I receive is transaction request, send it to that bank through IP add ......., if data is sign on send it to host,....). Is anyone know how I can do it?
TNX
nahitan
|
|
|
|
|
I am working on an application which will going to use OpenGL in 2 different locations.
#1. in DialogBar
#2. in CView
I implemented OpenGL for both, and they are working well when one of them is disabled. My problem is when both are active, confliction happens like they are trying to use opengl setup properties of each other like..if Dialog is wireframe CView turns into wireframe mode then crashes..
How can I prevent this, and let them work without touching each other.is Multi-threaded 2 different engine needed? ( As the example I gave above..they are using different views so I cant use 1 engine for both view. )
I am missknowledged about this type of OpenGL problems..
Any suggestion, articles are all welcome...and I ll be very glad...
thanks...
|
|
|
|
|
Hi all,
I'd like have some MDI child windows (Form View) like model dialogs, so that after closing the dialog only, I should even be able to access the main window (toolbar/menu/close button).
How to make it possible?
Thanks in advance,
Sarvan AL
|
|
|
|
|
So - what you want is a modal dialogue with a FormView(-derivation) inside?
There should be a few examples lying around here on CP.
"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, is there any VC++ add-in to automate variable/class renaming ?
|
|
|
|
|
on't know any for C++, but you could search for refactoring to get more answers...
|
|
|
|
|
Its called RefPP[^]and works quite well as my limited testing showed.
Also, the guys at refpp.com are quick with help and service.
All in all a fine tool!
"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.
|
|
|
|
|
Some time ago I happened upon an article (or maybe just a program )- with source code in C++, almost certainly MFC - implementing graphically a New York City/Manhattan path algorithm: that is a orthogonal polyline each of whose points' moves were constrained to the X and Y directions.
I think I saw it here on The Code Project.
Can somebody please point me to it?
TIA
alex
'Architecture is music frozen in space.'
|
|
|
|
|
|
Thank you for answering, but no.
It was either MFC or WIN32 (before C#, .net etc)
What I do remember, the demo drew a polyline (orthogonal segments only) and allowed the user to move those points while keeping the orthogonality.
alex
'Architecture is music frozen in space.'
|
|
|
|
|
Hi - I don't usually like to post questions which are "here's some code - why doesn't it work?" but I am well and truly stumped on this one...it's been more than a whole day's effort so far and it is 1025 on friday night and i'm still working on it....so i'd really appreciate some help...
I have two functions, one takes a buffer, turns it into PGM format (P6) and saves it to file....the other takes the buffer, turns it into PGM format in place and the calling function then returns the buffer and it is displayed
the saving to file one works a treat
<code>
/*
* writes a colour PGM file from a buffer
*/</code>
<code>
int write_P6(char *name, int W, int H, unsigned char *buf)
{
FILE *f;
int i, j;
if( (f = fopen(name, "w")) == NULL)
{
printf("Could not open >%s<\n", name);
return FALSE;
}
fprintf(f,"P6\n %d %d\n 255\n",W, H);
fflush(f);
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
fwrite(buf + (i * W + j)*3+2, 1, 1, f);
fwrite(buf + (i * W + j)*3+1, 1, 1, f);
fwrite(buf + (i * W + j)*3 , 1, 1, f);
}
}
fclose(f);
return TRUE;
}
</code>
and I am able to display the images just fine, but obviously this is sub-optimal and the disk accesses makes it real slow
so i want to use this function instead
<code>
/*********************************************************************/
/*
* changes a rgb buffer in place into PGM format without saving to disk
*/
int make_P6(int W, int H, unsigned char *buf)
{
int i, j;
unsigned char* temp;
temp = (unsigned char*)malloc(x * y *3+15);
sprintf(temp, "P6\n %d %d\n 255\n",W, H);
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
sprintf(temp, buf + (i * W + j)*3+2);
sprintf(temp, buf + (i * W + j)*3+1);
sprintf(temp, buf + (i * W + j)*3);
}
}
buf = (unsigned char*)realloc(buf, x * y *3+15);
buf = temp;
free(temp);
return TRUE;
}
</code>
the calling getframe function looks kinda like this:
<code>
unsigned char * getframe(int save_file)
{
int ret ;
ret = read(fd1, s, x * y);
if( ret != (x * y ) )
{
printf("We will have fragmented picture\n" );
}
nb_frame ++ ;
bayer2rgb24(d, s, x, y);
// at this point we should have a raw, RGB image
if( save_file )
{
write_P6("P6.pgm", x, y, d);
}
else
{
d = make_P6(x,y,d);
}
return d;
}
</code>
and the function which calls getframe knows whether to disregard the return value and open the file, or look at the return value for the pic....
now the problem comes in make_P6 --> the code just hangs at
<code> sprintf(temp, buf + (i * W + j)*3+2);
sprintf(temp, buf + (i * W + j)*3+1);
sprintf(temp, buf + (i * W + j)*3);</code>
- if i comment out these lines, there is no freeze (but clearly, nothing sensible happens to the image)....but if i leave them there, it just kinda waits....doing nothing....not crashing.....not taking up heaps of resources
it doesn't make any sense to me because the line
<code>sprintf(temp, "P6\n %d %d\n 255\n",W, H);</code>
works just fine....
i'll be eternally grateful if somebody can give me a hand
XX georgia
-- modified at 8:40 Friday 7th April, 2006
|
|
|
|
|
georgie.moss wrote: sprintf(temp, buf + (i * W + j)*3+2);
sprintf(temp, buf + (i * W + j)*3+1);
sprintf(temp, buf + (i * W + j)*3);
Of these three statements, only the last one is of any use since they are all writing to the same address. Is this your intent?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
sprintf expects to be working with NUL -terminated strings. If the buffer pointed to by buf + (i * W + j)*3+2 is garbage or does not have a NUL , it will keep looking for one. If that buffer contains a % it will try to format a value based on the contents of the stack, which would be bad considering to additional parameters are passed.
Are you sure you are not trying to do something like:
temp = (unsigned char*)malloc(x * y *3+15);
DWORD dwIndex = 0;
sprintf(temp, "P6\n %d %d\n 255\n",W, H);
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
DWORD dwBufIndex = ( i * W + j ) * 3 + 2;
temp[ dwIndex++ ] = buf[ dwBufIndex ]; <code>
temp[ dwIndex++ ] = buf[ --dwBufIndex ]; <code>
temp[ dwIndex++ ] = buf[ --dwBufIndex ]; <code>
}
} My math/indices may be off but I am sure you get what I am talking about...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
thanks - changing from sprintf to direct buffer manipulation did the trick
really appreciate the help
|
|
|
|
|
Hi
I am trying to add a couple of items to the status bar in my SDI app, i can add one item on no problem, but when i add a second one on,
i get a message box appear saying "failed to create empty document"
in MainFrm i have
static UINT indicators[] =
{
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
ID_INDICATOR_COUNT,
};
in the OnCreate
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndStatusBar.SetPaneInfo(3,ID_INDICATOR_COUNT, SBPS_STRETCH, NULL );
in my resource.h
#define ID_INDICATOR_COUNT 59142
but if i try to add another option on i get the error
any ideas ??
Si
|
|
|
|
|
IIRC, status bar indicators need to be string table entries, so try adding a string table entry for ID_INDICATOR_COUNT . Note that string table entries cannot be blank, and you will want to use enough characters for the width that the indicator will need.
For example, if you need to show a value range of 0-999999, I would create the string table entry with a string of "000000" . You can set the value of the indicator using an ON_COMMAND_UPDATE_UI for the ID_INDICATOR_COUNT "control".
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time..
Aljechin Alexander
|
|
|
|
|