double click event in ms-dos

C 16Bit (MS-DOS) Add comments

This program displays the click event of the mouse in ms dos environment using Turbo C. If you double click on the screen then you will get the message that you have double clicked else none. I wrote this function to use it in the 640×480 16 color graphics mode for a simple my computer program to which detects single click and double click on a file.

If people know about interrupts, ports, scan codes and button states then it might be useful for them if they are trying to under stand the concept of low level input and output. Using this may help them understand the windows env better…

and one more important point is i have used inline asm codes so … be ware…
here i would like to say one thing and that is about the inportb macro… using this i mimicked a multiprocessing program… which displays the time and at the same time it can detect the mouse and keyboard like in windows… i can never forget this word because i have used it very extensively.

anyway here is the code…

Interrupt 33 deals with the mouse and sub function 0 and 1 are for initialize mouse and show mouse pointer respectively… one interesting function i have made among the others… yeeeehaaawww…

#include<time.h>
#include<stdio.h>
#include<dos.h>
 
	char butt;
	clock_t start;
 
void main()
{
	void mouse();
	void click();
 
	start=clock();
 
	_AX=0;asm int 33h;
	_AX=1;asm int 33h;
 
	while(inportb(0x60)!=1)
	{
		mouse();
	    if(butt)
	    {
		click();
		while(butt)mouse();
	    }
	}
 
}
 
void click()
{
	float as;
	as=(float) start-clock();
 
	gotoxy(50,2);
 
	if(as>-6.&&as<0.)
		printf("double click");
	else
		printf("            ");
	start=clock();
}
 
void mouse()
{
	_AX=3;asm int 33h;
	butt=_BX;
}

Leave a Reply

Entries RSS