Compiler: Default compilerCode:#ifndef HITIMER_H #define HITIMER_H #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> #define TimerResolution 1000 //Milliseconds class HiTimer { private : LARGE_INTEGER freq; LARGE_INTEGER start; LARGE_INTEGER stop; bool available; public : HiTimer(); void SetTimer(); void StopTimer(); LONGLONG GetelapsedCount(); bool isavailable(); }; #include <iostream> #include <fstream> using namespace std; HiTimer Watch; unsigned int Count = 0; void MouseEventProc(MOUSE_EVENT_RECORD, ofstream & Output); bool _hasclick(void); int main(VOID) { HANDLE handleIn; INPUT_RECORD recordIn; DWORD NumRead; ofstream outputdata; outputdata.open("sample.txt"); if( !outputdata ) cerr << "Error: file could not be opened" << endl; //Get the handle to the console instance handleIn = GetStdHandle(STD_INPUT_HANDLE); if (handleIn == INVALID_HANDLE_VALUE) cerr << "Error:could not get instance"<<endl; // Enable the window and mouse input events. DWORD fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; if (! SetConsoleMode(handleIn, fdwMode) ) cerr << "Error:could not set mode"<<endl; while (Count < 100) { ReadConsoleInput(handleIn, &recordIn, 1, &NumRead); switch (recordIn.EventType) { case MOUSE_EVENT: MouseEventProc(recordIn.Event.MouseEvent, outputdata); break; } } outputdata.close(); cout<< "Finished check sample file"<<endl; cin.get(); return 0; } bool _hasclick(void) { static bool click = false; if(click = true ) return true; click = true; return false; } void MouseEventProc(MOUSE_EVENT_RECORD mer, ofstream & Output) { switch(mer.dwEventFlags) { case 0: if( mer.dwButtonState ==FROM_LEFT_1ST_BUTTON_PRESSED) { //do what you need to do if( _hasclick() ) { cout<<"You click"<<endl; Watch.StopTimer(); Output << Watch.GetelapsedCount() <<endl; } Watch.SetTimer(); } break; } } HiTimer::HiTimer() { start = 0; stop = 0; available = false; if(QueryPerformanceFrequency(&freq)) available = true; } void HiTime:: SetTimer() { QueryPerformanceCounter(&start); } void HiTime:: StopTimer() { QueryPerformanceCounter(&stop); } LONGLONG HiTime:: GetelapsedCount() { long long Time_elapsed = (stop.QuadPart - start.QuadPart) * TimerResolution / freq.QuadPart ; return Time_elapsed; } bool HiTime:: isavailable() { return available; }
Executing g++.exe...
g++.exe "C:\Users\Jim\Desktop\Samplecollector.cpp" -o "C:\Users\Jim\Desktop\Samplecollector.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Users\Jim\Desktop\Samplecollector.cpp: In constructor `HiTimer::HiTimer()':
C:\Users\Jim\Desktop\Samplecollector.cpp:128: error: no match for 'operator=' in '((HiTimer*)this)->HiTimer::start = 0'
C:/Dev-Cpp/include/winnt.h:1979: note: candidates are: _LARGE_INTEGER& _LARGE_INTEGER:perator=(const _LARGE_INTEGER&)
C:\Users\Jim\Desktop\Samplecollector.cpp:129: error: no match for 'operator=' in '((HiTimer*)this)->HiTimer::stop = 0'
C:/Dev-Cpp/include/winnt.h:1979: note: candidates are: _LARGE_INTEGER& _LARGE_INTEGER:perator=(const _LARGE_INTEGER&)
C:\Users\Jim\Desktop\Samplecollector.cpp: At global scope:
C:\Users\Jim\Desktop\Samplecollector.cpp:135: error: `HiTime' has not been declared
C:\Users\Jim\Desktop\Samplecollector.cpp: In function `void SetTimer()':
C:\Users\Jim\Desktop\Samplecollector.cpp:137: error: `start' undeclared (first use this function)
C:\Users\Jim\Desktop\Samplecollector.cpp:137: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Users\Jim\Desktop\Samplecollector.cpp: At global scope:
C:\Users\Jim\Desktop\Samplecollector.cpp:140: error: `HiTime' has not been declared
C:\Users\Jim\Desktop\Samplecollector.cpp: In function `void StopTimer()':
C:\Users\Jim\Desktop\Samplecollector.cpp:142: error: `stop' undeclared (first use this function)
C:\Users\Jim\Desktop\Samplecollector.cpp: At global scope:
C:\Users\Jim\Desktop\Samplecollector.cpp:145: error: `HiTime' has not been declared
C:\Users\Jim\Desktop\Samplecollector.cpp: In function `LONGLONG GetelapsedCount()':
C:\Users\Jim\Desktop\Samplecollector.cpp:147: error: `stop' undeclared (first use this function)
C:\Users\Jim\Desktop\Samplecollector.cpp:147: error: `start' undeclared (first use this function)
C:\Users\Jim\Desktop\Samplecollector.cpp:147: error: `freq' undeclared (first use this function)
C:\Users\Jim\Desktop\Samplecollector.cpp: At global scope:
C:\Users\Jim\Desktop\Samplecollector.cpp:151: error: `HiTime' has not been declared
C:\Users\Jim\Desktop\Samplecollector.cpp: In function `bool isavailable()':
C:\Users\Jim\Desktop\Samplecollector.cpp:153: error: `available' undeclared (first use this function)
Execution terminated



LinkBack URL
About LinkBacks
perator=(const _LARGE_INTEGER&)


