
03-Dec-2005, 12:32
|
|
New Member
|
|
Join Date: Dec 2005
Posts: 1
|
|
|
Urgent help needed:mouse position problem
i am developing a simple paint program in c++.
Whenever the user clicks with the mouse pointer on the screen,those coordinates are returned in the function and the pixel ther is switched on BUT the problem is that, whenever i click on the mousepointer instead of the pixel being switched at that point it is swtched on further away from the actual position,Can some body tell me that what the problem might be?
#include"interface.cpp"
//#include<graphics.h>
int initmouse();
void showmouseptr();
void restrictmouseptr(int , int , int , int );
void getmousepos(int *, int *, int *);
void main()
{
mode(19);// function called from tool.cpp to change the mode to graphics
draw_rec();
int x1=0;
int y1=0;
int maxx,maxy, x, y,button;
showmouseptr();
int prevx=0;
int prevy=0;
while(!kbhit())
{
getmousepos(&button,&x,&y);
if(button ==1 )
{
prevx=x;
prevy=y;
while(button ==1)
{
linebress(prevx,prevy,x,y,4);//function called to switch the pixel on
prevx = x;
prevy = y;
getmousepos(&button ,&x,&y);
}//end while
showmouseptr();
}//end if
}//end while
getch();
}
void showmouseptr()
{
r.x.ax=1;
int86(0x33, &r,&r);
}
int initmouse()
{
r.x.ax=0;
int86(0x33,&r,&r);
return(r.x.ax);
}
void getmousepos(int *button, int *x, int *y)
{
r.x.ax =3;
int86(0x33, &r,&r);
*button = r.x.bx;
*x = r.x.cx;
*y=r.x.dx;
}
Last edited by LuciWiz : 03-Dec-2005 at 12:57.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|