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 2094
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
horace1 1,510
Recognized Expert Top Contributor
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
DeMan 1,806
Top Contributor
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
DeMan 1,806
Top Contributor
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 double-checked the path to my error log. It is in
/var/www/logs/php_error_log
Thanks. :)
-Wayne Stevenson
|
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 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select database();
+------------+
| database() |
+------------+
|
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 should view the .msi file, but I don't
know how.
My Solution has several dlls in its hierarchy.
Can someone help me out?
Thanks,
Dennis
|
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 VALUE ENTERED BY THE USER EXISTS IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-...
|
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
using sid, and I mean not even a word, or even part of a word, in that
document or any of the include documents.
| |
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 you wish to automate please send the
standard to us in PDF format so we can assist in developing the
automation with codecheck.
If you are developing codecheck rule-files and have a particular
|
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 some problems facing..
1: How to match both txt box vlaues that r same or not.Is there php code for it.
2: I want to put a print button in the code where the code display the page after
entring the icnumber and after submit.
3: How to show the...
|
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);
....
pnlImageIndex.Controls.Add(pb);
|
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge.
I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge.
I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |