Alright, I have this code. The idea of the code is to click on the X button to exit . My problem occurs since I can't check to see if there was a mouse click...or if there was input...and if there was input...that would be it, as in i would not need an extra cin statement. I basically need the code that checks if the X has been clicked to be constantly running, while other things are still going on.
ThanksCode:#include <windows.h> #include <conio.h> #include <iostream> using namespace std; main(){ SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ENABLE_ECHO_INPUT|ENABLE_MOUSE_INPUT); bool Continue=1; INPUT_RECORD InputRecord; DWORD Events=0; int value; int total=0; int lowest_temp=999999; int highest_temp=-999999; COORD dwCursorPosition={78,24}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),dwCursorPosition); cout<<'X'; dwCursorPosition.X=0; dwCursorPosition.Y=0; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),dwCursorPosition); cout<<"Enter any number of temperatures, with a keypress between entries." <<"\nClick the X button to exit.\n"; int count=0; while(Continue==1){ cout<<"Enter temperature: "; ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE),&InputRecord,1,&Events); if(InputRecord.Event.MouseEvent.dwMousePosition.X==78&&InputRecord.Event.MouseEvent.dwMousePosition.Y==24){ Continue=0; } else{ cin>>value; if(value<lowest_temp){ lowest_temp=value; if(value>highest_temp) highest_temp=value; } else if(value>highest_temp){ highest_temp=value; if(value<lowest_temp) lowest_temp=value; } total+=value; } count++; } total/=(double)(count-1); cout<<"\nThe Highest temperature was: "<<highest_temp; cout<<"\nThe Lowest temperature was: "<<lowest_temp; cout<<"\nThe average temperature was: "<<total<<'\n'; return 0; }



LinkBack URL
About LinkBacks


