Thread: Visual C++ 6.0 Console Application

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    1

    Exclamation Visual C++ 6.0 Console Application

    Hello.

    How can i this algorithm in VC++ in a win32 console application:

    if (left_mouse_button=clicked) and
    (x>10) and (x<20) and (y=5)
    then ...

    (I program 100% of time in delphi and a little in C++ but i have to do a program to a discipline in university...)

    In assembly and in turbo c++ i know how to work with mouse but in VC++ in console mode i don't know because it brings the blue screen.

    Thanx...

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can read the mouse buttons like this -

    Code:
    #include <iostream>
    #include <windows.h>
    using namespace std;
    
    
    int main() {
    
    	INPUT_RECORD ir;
    	DWORD read;
    	HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
    	SetConsoleMode(h, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);	
    
    		while(1)
    		{
    			FlushConsoleInputBuffer(h);
    
    			ReadConsoleInput(h,&ir,1,&read);
    			if(ir.Event.MouseEvent.dwButtonState&FROM_LEFT_1ST_BUTTON_PRESSED)
    				cout << "left button" << endl;
    
    			
    		}
    	
        return 0;
    }
    **Note - the only way I could get this to work properly was either running the console full screen or disabling QuickEdit Mode from the console properties.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Console Application
    By Mont_Blanc in forum C++ Programming
    Replies: 3
    Last Post: 04-17-2004, 03:07 AM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. header file bringing errors?
    By bluehead in forum Windows Programming
    Replies: 4
    Last Post: 08-19-2003, 12:51 PM