SunQuest
           C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 11th, 2002, 11:11 PM
Optix Optix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 36 Optix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Problem Running Example..

Hi,

I was over at pscode.com and ran across an example for Mouse Programming. I tried running the example but I was getting a bunch of errors such as..

c:\Documents and Settings\default\My Documents\Visual Studio Projects\mouse\mouse.cpp(33): error C2065: '_AX' : undeclared identifier

c:\Documents and Settings\default\My Documents\Visual Studio Projects\mouse\mouse.cpp(34): error C2065: 'geninterrupt' : undeclared identifier

c:\Documents and Settings\default\My Documents\Visual Studio Projects\mouse\mouse.cpp(58): error C2065: '_CX' : undeclared identifier

Here is the code for the example:

Code:
//The Compiler used is Turbo C, I dont know if it will compile in others also.
//Didn't Compile in Microsoft C Compiler. Make the respective change then.
//The function geninterrupt() generates interrupts, it is defined in dos.h
//_AX,_BX,_CX,_DX are defined in dos.h & correspond to ax,bx,cx,dx registers respectively.
//Make a header file out of this one and use it in your programs.
#include<dos.h>//this header file is necessary
#include<stdio.h>//only for displaying messages
#include<conio.h>//for other stuff like getch() etc.
unsigned initmouse()
{
	_AX=0;
	geninterrupt(0x33);	//Generate Inpterrupt
	return _AX;
}

void showmouse()
{
	_AX=1;
	geninterrupt(0x33);
}

void hidemouse()
{
	_AX=2;
	geninterrupt(0x33);
}

void restrictmouse(int x1,int y1,int x2,int y2)
{
	_AX=7;
	_CX=x1;
	_DX=x2;
	geninterrupt(0x33);
	_AX=8;
	_CX=y1;
	_DX=y2;
	geninterrupt(0x33);
}

void getmouse(int *button,int *x,int *y)
{
	_AX=3;
	geninterrupt(0x33);
	*button=_BX;
	*x=_CX;
	*y=_DX;
}

void setmouse(int x,int y)
{
	_AX=4;
	_CX=x;
	_DX=y;
	geninterrupt(0x33);
}

void main()
{
	int x,y,button;
	clrscr();
	gotoxy(29,18);
	textbackground(GREEN);
	cprintf("EXIT");
	gotoxy(1,1);
	if(initmouse()==0)
	{
		printf("Mouse support unavailable");
		return;
	}
	printf("\n\nPress any key to Show Mouse");
	getch();
	showmouse();
	printf("\nPress any key to Hide Mouse");
	getch();
	hidemouse();
	printf("\nPress any key to Show Mouse again");
	getch();
	restrictmouse(208,80,416,160);
	showmouse();
	printf("\nMouse has been restricted");
	printf("\nPress on Exit button to quit the Program");
	while(1)
	{
		getmouse(&button,&x,&y);
		gotoxy(35,1);
		printf("Coordinates:-(%d,%d)  ",x,y);
		gotoxy(35,2);
		if(button&1)//<- Here '&' means ANDing, remember bitwise operators of C/C++
			printf("Left button pressed  ");
		else if(button&2)
			printf("Right button pressed ");
		else if(button&4)
			printf("Center button pressed");
		else
			printf("No button Pressed    ");
		if(x>=224&&x<=248&&y==136&&button==1)//checks if exit button is pressed or not
			break;
	}
}


As you can see in the comments, it says "_AX,_BX,_CX,_DX are defined in dos.h & correspond to ax,bx,cx,dx registers respectively." dos.h is included in this example, so does anyone know why I am getting these errors?

Thanks.

-0pt!x

Reply With Quote
  #2  
Old November 12th, 2002, 03:09 AM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 594 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 14 h 6 m 15 sec
Reputation Power: 21
You could always OPEN dos.h and SEE if they are defined. (highlight the text 'dos.h' RIGHT click and select 'open document "dos.h" ' from the pop-up menu in MS Visual Studio (i know it is in from ver 5)



And then find they are not in dos.h.

"//The Compiler used is Turbo C, I dont know if it will compile in others also.
//Didn't Compile in Microsoft C Compiler."
__________________
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

Frank Zappa

Reply With Quote
  #3  
Old November 12th, 2002, 08:59 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Even though dos.h was included with the code, I don't think you are calling that file that.
by using: #include<dos.h>
you are including the dos.h file from your compiler's include path. If you want to use a different dos.h file then the one that is in the include path, then give the complete path to it. i.e.
#include "drive:/path/to/dos.h"

Reply With Quote
  #4  
Old November 12th, 2002, 07:47 PM
Optix Optix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 36 Optix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Well I want to use the dos.h that came with my compiler. I looked in the header and it didnt define the _AX and stuff.. But .. I am confused because it says that it is sposed to be defined in my dos.h. Is my dos.h screwed up or something?

Reply With Quote
  #5  
Old November 12th, 2002, 07:52 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
quite possible.

Reply With Quote
  #6  
Old November 12th, 2002, 09:03 PM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 594 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 14 h 6 m 15 sec
Reputation Power: 21
>>Is my dos.h screwed up or something?

No. It is a just a difference between compliers.

as the code stated and I pointed out

"//The Compiler used is Turbo C, I dont know if it will compile in others also.
//Didn't Compile in Microsoft C Compiler."

Is that not clear enough for you?

You are obviously using a Microsoft Compiler, a version of MSVC

"c:\Documents and Settings\default\My Documents\Visual Studio Projects\"



What did you want to do with the mouse?

Reply With Quote
  #7  
Old November 12th, 2002, 10:10 PM
Optix Optix is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 36 Optix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I know i was using a diff compiler but shouldnt the header files be the same?

>>What did you want to do with the mouse?

I wanted to make a prog that would click the mouse every 1 second untill i closed my prog. Like..

int main()
{
while(1)
{
click;
sleep(1000);
}
}

somethin like that.

Reply With Quote
  #8  
Old November 13th, 2002, 02:20 AM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 594 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 14 h 6 m 15 sec
Reputation Power: 21
>>I know i was using a diff compiler but shouldnt the header files be the same?

No.


A good coder comments his work and its limitations. This coder did, bad coders ignore instructions and commented code.
In the comments the coder TOLD you it would not compile in MSVC, he could not have been plainer. You have MSVC.

Did you not READ that line or did you not UNDERSTAND that line? (the bold one above)

If in doubt RTFM!

Ahhh
Some app that pretends you are still there surfing away.


If they had any sense when they wrote it they will have locked out external use of SendMessage() like functions.

If you can't read simple code comments then a WIN32 API app that sends mouse click messages to another application is most definately beyond the scope of your abilites.

You most probably need to send mouse messages thru windows to the other app as you will not know the client co-ordinates that the ckick happens at. That is WHERE the mouse is clicked ( in the other apps client coodinates).
Try a search for mouse_event(), which has been superceded by SendInput () ect. See what it turns up.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Problem Running Example..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway