well i have my mouse working and now im trying to make my exit button working when the mouse clicked onto exit button and it will exit the application
here is my coding for the mouse function to exit the application
.................................................. .................................................. ..............
//The function getmousepos gets the position of the mouse alongwith the mouse button state. Like which
//button is pressed 1,2. If button =1 then it is left mouse and if it is 2 then right mouse button click. -
void getmousepos(int *button,int *x,int *y)
-
{
-
char *ss;
-
union REGS i,o;
-
i.x.ax=3;
-
int86(0x33,&i,&o);
-
*button=o.x.bx;
-
*x=o.x.cx;
-
*y=o.x.dx;
-
}
-
-
-
-
//The below loop executes until anything is pressed and then getmousepos is called to get the position of
-
//the mouse and if it falls in between x>=70 && x<=100 && y>=410 && y<=420 then exit from the program.
-
//void thisismycode()
-
{
-
while(!kbhit())
-
{
-
getmousepos(&button,&x,&y);
-
if((button&1)==1)
-
{
-
getmousepos(&button,& x,& y);
-
if(x>=70 && x<=100 && y>=410 && y<=420)
-
exit(0);
-
}
-
}
-
-
}
-
-
.................................................. .................................................. ............
My error message when i complile
undefined symbol 'button'
undefined symbol 'x'
undefined symbol 'y'
.................................................. .................................................. .............
what have i done.. have i missed something there..
8 2054
where u define these variables ??????
where u define these variables ??????
how you mean where i define these variables???
well im using old version of turbo c
how you mean where i define these variables???
well im using old version of turbo c
need to define button, x and y and initialise the mouse - try this as a test program -
int main()
-
{
-
int button, x,y; // << define variables
-
union REGS registers; /* variable to hold 8086 registers */
-
-
registers.x.ax = 0; /* reset the Microsoft mouse */
-
int86(0x33, ®isters, ®isters);
-
while(!kbhit())
-
{
-
getmousepos(&button,&x,&y);
-
printf("%d %d %d \n", button, x, y);
-
if((button&1)==1)
-
{
-
getmousepos(&button,& x,& y);
-
if(x>=70 && x<=100 && y>=410 && y<=420)
-
exit(0);
-
}
-
}
-
-
}
-
-
/* list the include file */
-
/*#include <direct.h>*/
-
#include <conio.h>
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <math.h>
-
#include <string.h>
-
#include <time.h>
-
#include <ctype.h>
-
#include <dos.h>
-
#include <graphics.h>
-
-
-
/* check the colours !!!! */
-
int black = 0;
-
int deepblue = 1;
-
int deepgreen = 2;
-
int deepcyan = 3;
-
int deepred = 4;
-
int deepmagenta= 5;
-
int brown = 6;
-
int gray = 7;
-
int blue = 8;
-
int green = 10;
-
int cyan = 11;
-
int red = 12;
-
int magenta = 13;
-
int yellow = 14;
-
int white = 15;
-
-
int yline0= 0 ; /* position of a Y line */
-
int yline1= 20 ; /* position of a Y line */
-
int yline2= 40 ; /* position of a Y line */
-
int yline3= 60 ; /* position of a Y line */
-
int yline4= 80 ; /* position of a Y line */
-
int yline5= 100 ; /* position of a Y line */
-
int yline6= 120 ; /* position of a Y line */
-
int yline7= 140; /* position of a Y line */
-
int yline8= 160; /* position of a Y line */
-
int yline9= 180; /* position of a Y line */
-
int yline10 = 200 ; /* position of a Y line */
-
int yline11 = 220 ; /* position of a Y line */
-
int yline12 = 240 ; /* position of a Y line */
-
int yline13 = 260 ; /* position of a Y line */
-
int yline14 = 280 ; /* position of a Y line */
-
int yline15 = 300 ; /* position of a Y line */
-
int yline16 = 320 ; /* position of a Y line */
-
int yline17 = 340; /* position of a Y line */
-
int yline18 = 360 ; /* position of a Y line */
-
int yline19 = 380 ; /* position of a Y line */
-
int yline20 = 400 ; /* position of a Y line */
-
int yline21 = 420 ; /* position of a Y line */
-
int yline22 = 440 ; /* position of a Y line */
-
int yline23 = 460 ; /* position of a Y line */
-
void heading(char *string);
-
void centreline(char *string);
-
void gcls(void) ;
-
void gsolidrectangle(int x1, int y1, int x2, int y2,int col);
-
-
//mouse int function
-
int GetX(void);
-
int GetY(void);
-
int GetKey(void);
-
void ShowCursor(void);
-
void HideCursor(void);
-
int ButtonStatus(void);
-
void SetMouseMode(int);
-
void PrintMousePosition(void);
-
void UpdateMousePosition(void);
-
void PrintMouseButtonStatus(void);
-
void UpdateMouseButtonStatus(void);
-
void CheckMouseButtonStatus(void);
-
void DrawOneButton(void);
-
void OnButtonClick(void);
-
void LabelButtons(void);
-
void RelabelButtons(int);
-
void About(void);
-
void InitializeMouse(void);
-
void Startup(void);
-
void LoadOne(void);
-
void RestrictMouse(int,int,int,int);
-
-
// cpu register structure for dos function calls.
-
struct REGPACK reg;
-
union REGS regs;
-
-
-
//Mouse function coding here..
-
-
int GetX(void)
-
{
-
// get mouse X position
-
reg.r_ax=3;
-
intr(51,®);
-
return(reg.r_cx);
-
}
-
-
int GetY(void)
-
{
-
// get mouse Y position
-
reg.r_ax=3;
-
intr(51,®);
-
return(reg.r_dx);
-
}
-
-
-
void ShowCursor(void)
-
{
-
// Turn on mouse cursor
-
reg.r_ax=1;
-
intr(51,®);
-
}
-
-
void HideCursor(void)
-
{
-
// Turn off mouse cursor.
-
reg.r_ax=2;
-
intr(51,®);
-
}
-
-
void RestrictMouse(int x1,int y1,int x2,int y2)
-
{
-
union REGS i,o;
-
i.x.ax=7;
-
i.x.cx=x1;
-
i.x.dx=x2;
-
int86(0x33,&i,&o);
-
-
i.x.ax=8;
-
i.x.cx=y1;
-
i.x.dx=y2;
-
int86(0x33,&i,&o);
-
}
-
void getmousepos(int *button,int *x,int *y)
-
{
-
char *ss;
-
union REGS i,o;
-
i.x.ax=3;
-
int86(0x33,&i,&o);
-
*button=o.x.bx;
-
*x=o.x.cx;
-
*y=o.x.dx;
-
}
-
-
void CheckMouseButtonStatus(void)
-
{
-
// gets mouse buttons pressed.
-
-
/* status=ButtonStatus();
-
-
LeftButton=0;
-
RightButton=0;
-
MiddleButton=0;
-
-
if(status==1){LeftButton=1;}
-
if(status==2){RightButton=1;}
-
if(status==3){LeftButton=1;RightButton=1;}
-
if(status==4){MiddleButton=1;}
-
if(status==5){LeftButton=1;MiddleButton=1;}
-
if(status==6){LeftButton=1;MiddleButton=1;}
-
if(status==7){LeftButton=1;RightButton=1;MiddleButton=1;}*/
-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
int main()
-
{
-
/* request auto detection */
-
int gdriver = DETECT, gmode, errorcode,button=1,x,y;
-
-
/* initialize graphics mode */
-
initgraph(&gdriver, &gmode, "c:\\turboc");
-
-
/* read result of initialization */
-
errorcode = graphresult();
-
-
if (errorcode != grOk) /* an error occurred */
-
{
-
printf("Graphics error: %s\n", grapherrormsg(errorcode));
-
printf("Press any key to halt:");
-
getch();
-
exit(1); /* return with error code */
-
}
-
-
/* do some graphics */
-
//Heading
-
-
-
-
//green background
-
gsolidrectangle(640,570,0,0,deepcyan );
-
//text
-
setcolor(black);
-
moveto(515,130);
-
outtext("Control Panel");
-
setcolor(black);
-
rectangle(500,150,620,350);
-
rectangle(510,160,610,180);//screen
-
gsolidrectangle(510,160,610,180,cyan); //colour screen
-
//1st row button
-
rectangle(515,210,540,190);
-
rectangle(572,210,545,190);
-
rectangle(605,210,581,190);
-
moveto(525,200);
-
outtext("1"); //text keypad 1
-
moveto(555,200);
-
outtext("2"); //text keypad 2
-
moveto(590,200);
-
outtext("3"); //text keypad 3
-
-
//2nd row button
-
rectangle(515,220,540,243);
-
rectangle(572,220,545,243);
-
rectangle(580,220,605,243);
-
moveto(525,230);
-
outtext("4"); //text keypad 4
-
moveto(555,230);
-
outtext("5"); //text keypad 5
-
moveto(590,230);
-
outtext("6"); //text keypad 6
-
-
//3rd row button
-
rectangle(540,275,515,250);
-
rectangle(574,275,545,250);
-
rectangle(605,275,580,250);
-
moveto(525,260);
-
outtext("7"); //text keypad 7
-
moveto(555,260);
-
outtext("8"); //text keypad 8
-
moveto(590,260);
-
outtext("9"); //text keypad 9
-
-
//4th row button
-
rectangle(540,305,515,279);
-
rectangle(574,305,545,280);
-
rectangle(605,305,580,280);
-
moveto(525,290);
-
outtext("*"); //text keypad *
-
moveto(555,290);
-
outtext("0"); //text keypad 0
-
moveto(590,290);
-
outtext("#"); //text keypad #
-
-
-
//background of rectangle
-
gsolidrectangle(10,100,100,120,cyan);
-
gsolidrectangle(10,140,100,160,green);
-
gsolidrectangle(10,180,100,200,yellow);
-
gsolidrectangle(10,220,100,240,deepmagenta);
-
gsolidrectangle(10,260,100,280,deepgreen);
-
gsolidrectangle(10,300,100,320,cyan);
-
-
setcolor(deepblue);
-
rectangle(10,100,100,120);
-
rectangle(10,140,100,160);
-
rectangle(10,180,100,200);
-
rectangle(10,220,100,240);
-
rectangle(10,260,100,280);
-
rectangle(10,300,100,320);
-
-
//switch box
-
-
moveto(390,130);
-
outtext("Switch Box");
-
setcolor(black);
-
rectangle(490,350,350,150);
-
gsolidrectangle(450,160,485,190,red);//sw switch select
-
circle(468,175,10);
-
moveto(355,170);
-
outtext("SW Select");
-
//bit0 switch
-
gsolidrectangle(450,220,485,195,red);//bit0 switch
-
circle(468,207,10);
-
moveto(360,205);
-
outtext("Bit-0");
-
//bit1 switch
-
gsolidrectangle(450,250,485,225,red);//bit1 switch select
-
circle(468,237,10);
-
moveto(360,235);
-
outtext("Bit-1");
-
//bit2 switch
-
gsolidrectangle(450,280,485,255,red);//bit2 switch
-
circle(468,267,10);
-
moveto(360,265);
-
outtext("Bit-2");
-
gsolidrectangle(450,310,485,285,red);//bit2 switch
-
circle(468,297,10);
-
moveto(360,295);
-
outtext("Bit-3");
-
-
//middle button for sw swtich
-
circle(468,175,5);
-
moveto(355,170);
-
//middle button for bit-0
-
circle(468,207,5);
-
moveto(360,205);
-
//middle button for bit-1
-
circle(468,237,5);
-
moveto(360,235);
-
//middle button for bit-2
-
circle(468,267,5);
-
moveto(360,265);
-
//middle button for bit-3
-
circle(468,297,5);
-
moveto(360,295);
-
-
//Instruction box
-
rectangle(345,450,620,360);
-
moveto(360,370);
-
outtext("1 - Press S Start Motor");
-
moveto(360,390);
-
outtext("2 - Press T stop motor");
-
moveto(360,410);
-
outtext("3 - Press O Heater on");
-
moveto(360,430);
-
outtext("4 - Press 1 Heater off");
-
-
//Temperature box
-
rectangle(350,80,620,110);
-
gsolidrectangle(480,85,580,100,red);
-
moveto(360,90);
-
outtext("Temperature:");
-
-
//ON and OFF Switches
-
rectangle(350,60,620,10);
-
moveto(360,20);
-
outtext("Switches ON/OFF");
-
circle(361,40,5);
-
moveto(370,40);
-
outtext("ON");
-
circle(420,40,5);
-
moveto(430,40);
-
outtext("OFF");
-
-
//restart button
-
circle(500,40,5);
-
moveto(510,40);
-
outtext("Restart");
-
-
//Exit Button
-
rectangle(48,428,123,398);
-
gsolidrectangle(50,425,120,400,red);
-
moveto(70,410);
-
outtext("EXIT");
-
-
-
ShowCursor();
-
RestrictMouse(0,0,getmaxx(),getmaxy());
-
int main()
-
{
-
int button, x,y; // << define variables
-
union REGS registers; /* variable to hold 8086 registers */
-
-
registers.x.ax = 0; /* reset the Microsoft mouse */
-
int86(0x33, ®isters, ®isters);
-
while(!kbhit())
-
{
-
getmousepos(&button,&x,&y);
-
printf("%d %d %d \n", button, x, y);
-
if((button&1)==1)
-
{
-
getmousepos(&button,& x,& y);
-
if(x>=70 && x<=100 && y>=410 && y<=420)
-
exit(0);
-
}
-
}
-
-
}
-
-
void heading(char *string)
-
{
-
gcls() ;
-
moveto(320 - (strlen(string) * 8) , yline0); /* centre text */
-
settextstyle(0,0,2);
-
outtext(string) ; /* print text */
-
settextstyle(0,0,1);
-
}
-
-
void centreline(char *string)
-
{
-
int length,start ;
-
start = ((80 - strlen(string))/2) * 8 ;
-
length = strlen(string) *9 ;
-
rectangle(start-6,yline11 - 10, start + length + 16 , yline12 + 10);
-
rectangle(start-4,yline11 - 8, start + length + 14 , yline12 + 8);
-
moveto(start + 10, yline11); /* centre text */
-
outtext(string) ; /* print text */
-
}
-
-
/* clear the screen */
-
void gcls(void)
-
{
-
gsolidrectangle(0,0,639,479,black);
-
}
-
-
/* draw solid rectangle */
-
void gsolidrectangle(int x1, int y1, int x2, int y2,int col)
-
{
-
int poly[8],tcol;
-
tcol = getcolor();
-
poly[0] = poly[6] = x1; /* 1st vertex */
-
poly[1] = poly[3] = y1;
-
poly[2] = poly[4] = x2; /* 1st vertex */
-
poly[7] = poly[5] = y2;
-
setfillstyle(SOLID_FILL,col);
-
setcolor(col);
-
fillpoly(4, poly);
-
setcolor(tcol);
-
}
-
hi.
I have managed to correct from your code to mine.. some how i got an error saying
please check above thanks
Declaration is not allowed here
Declaration syntax error
Declaration missing ;
function should return a value
I can see two implementations of main. The second one comes ion the middle of the first, and I suspect the parentheses are mixed up as a result. So: get rid of the second "int main()" and then make sure all your parentheses line up as required...
I can see two implementations of main. The second one comes ion the middle of the first, and I suspect the parentheses are mixed up as a result. So: get rid of the second "int main()" and then make sure all your parentheses line up as required...
i have managed to get rid of the main int() in the middle.. still same error message
please help any1
Might like to move the iont and union declarations (where the int main() originally was) up to the top of teh method.....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Wayno |
last post by:
My php logs are coming up empty. I have done all I can think of, and
all that made sense to me. Can someone take a look at my php.ini
please and tell me what you think may be the problem.
I...
|
by: Morten Gulbrandsen |
last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug
Type...
|
by: db_from_mn |
last post by:
Using Visual Studio, 2003:
When I create a deployment project and try to install it, I get Installer
Error 2705: Invalid Table, Could not be linked as tree.
How can I debug this? It seems that I...
|
by: pmud |
last post by:
Hi,
I am using a compare validator in asp.net application(c# code). This Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the...
|
by: Adrienne Boswell |
last post by:
I am getting this error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'sid'
/beta/files/index.asp
There is no line number, and there is absolutely nothing on that page...
|
by: pat |
last post by:
CodeCheck Coding Standard's Support
As a free service to our customers we offer support in developing
"rule-files" for automating corporate coding standards.
If you have a coding standard that...
|
by: mmarif4u |
last post by:
Hi everyone.
i make a page that a user input thier icnumber with confirm ic number,
it saves the data to mysql db with current date and a random access code
generated automatically, NOW i have...
|
by: Cruithne3753 |
last post by:
I'm trying to create a Windows app with a clickable index of images
within a local folder.
Within a loop I've got:-
PictureBox pb = new PictureBox();
pb.Image = Image.FromFile(file);
.......
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |