[C / C ] Click in Dev-C – Mouse event in Dev-C

In this article I will walk on some of the functions and event click mode Dev-C graphics.

void getmouseclick( int kind, int& x, int& and );
-> obtain the coordinates x,and ( in pixels) where can click
bool ismouseclick( int kind );
-> returns true if there is a click
int mousex( ); -> mouse coordinates in the x
int mousey( ); -> mouse coordinates y-axis

WM_MOUSEMOVE : catch event when moving the mouse in the graphic display
WM_LBUTTONDBLCLK : catch event when double-clicking the left mouse
WM_LBUTTONDOWN : catch event when clicking the left mouse
WM_LBUTTONUP : catch event when released after pressing the left mouse
Similar between mice and rats have
WM_MBUTTONDBLCLK
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_RBUTTONDBLCLK
WM_RBUTTONDOWN
WM_RBUTTONUP

There are many other functions you see here: http://www.cs.colorado.edu/~main/bgi/doc/

A code snippet illustrates capture mouse events left, right.

#include <winbgim.h>
#include <stdio.h>
#include <string.h>

int main(){
	setbkcolor(1);
	int x, y;
	initwindow(800,500);
    setbkcolor(15);
   	cleardevice();
	while (1){
		delay(0.0001);

		if (ismouseclick(WM_LBUTTONDOWN)){
			getmouseclick(WM_LBUTTONDOWN, x, y);
			printf("left click : (%d,%d)n", x, y);
		}

		if (ismouseclick(WM_LBUTTONUP)){
			getmouseclick(WM_LBUTTONUP, x, y);
			printf("left up click : (%d,%d)n", x, y);
		}

		if (ismouseclick(WM_LBUTTONDBLCLK)){
			getmouseclick(WM_LBUTTONDBLCLK, x, y);
			printf("left double click : (%d,%d)n", x, y);
		}

		if (ismouseclick(WM_RBUTTONDOWN)){
			getmouseclick(WM_RBUTTONDOWN, x, y);
			printf("right click : (%d,%d)n", x, y);
		}

		if (ismouseclick(WM_RBUTTONUP)){
			getmouseclick(WM_RBUTTONUP, x, y);
			printf("right up click : (%d,%d)n", x, y);
		}

		if (ismouseclick(WM_RBUTTONDBLCLK)){
			getmouseclick(WM_RBUTTONDBLCLK, x, y);
			printf("right double click : (%d,%d)n", x, y);
		}
		if (ismouseclick(WM_MOUSEMOVE)){
			getmouseclick(WM_MOUSEMOVE, x, y);
			printf("move : (%d,%d)n", x, y);
		}
	}
	system("pause");
	closegraph();
}

Results to click and move the mouse in the graphic display:
mouse event in Dev-C
A video I come straight line drawn with the mouse but still not ready for errors:

Refer: Graphics in Dev-C