Thread: Multiple Processes maybe?

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    70

    Multiple Processes maybe?

    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.
    Code:
    #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;
    }
    Thanks

  2. #2
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    I don't think you can do that with the console. It's a text interface and it's not designed to handle mouse inputs. Maybe try to capture the mouse position and if it has a click. msdn.microsoft.com should be a point of reference.
    Don't hold much hope though
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tracking Multiple Processes in C Application
    By dunxton in forum C Programming
    Replies: 1
    Last Post: 05-05-2009, 03:19 AM
  2. Fork multiple processes()??
    By Paul22000 in forum C Programming
    Replies: 8
    Last Post: 11-12-2008, 04:47 PM
  3. Same pipe to multiple processes?
    By Ironic in forum C Programming
    Replies: 7
    Last Post: 10-25-2008, 10:10 AM
  4. shared libraries, datasegment and multiple processes
    By ashim_k1 in forum Linux Programming
    Replies: 1
    Last Post: 02-28-2008, 02:23 PM
  5. Multiple processes
    By cpsh007 in forum C Programming
    Replies: 10
    Last Post: 11-22-2007, 05:30 AM