Solved

newbie ?s: using the mouse and accessing text files oh and one question about strings

Posted on 2004-04-09
6
260 Views
Last Modified: 2010-04-15
how do i dispay a mouse cursor in my programs? and how do i get my program to find out where it is on the screen. how do i read a text file into a string? and how do i find out how many charachters there are in a string.

i know these should be in seperate questions but i do not have enough points

thanks
ico2
0
Comment
Question by:ico2
  • 3
  • 2
6 Comments
 
LVL 45

Expert Comment

by:Kdo
ID: 10792782
Hi ico2,

The simple question first.  :)

  strlen (String);

This will return the number of characters in the string.  Note that the string is actually one character longer than this!

Cursor management varies with the operating system and device interfaces.

What system are you using?


Good Luck,
Kent
0
 
LVL 2

Expert Comment

by:Avik77
ID: 10792791
Assuming u to be working in DOS environment..
For displaying mouse cursor u require to work with interrupts using function int86 provided in dos.h. u can check the help for its format.
First u have to initialise the mouse cursor using
int initmouse()
{
 i.x.ax=0;
 int86(0x33,&i,&o);
 return(o.x.ax);
}
if return value is 1. then show/display mouse pointer by
void showmouseptr()
{
 i.x.ax=1;
 int86(0x33,&i,&o);
}
u can get mouse position by
void getmousepos()
{
 i.x.ax=3;
 int86(0x33,&i,&o);
 button=o.x.bx;
 X=o.x.cx;
 Y=o.x.dx;
}
X and Y are the(x,y) co-ordinates on the screen. Declare X,Y as global variables to always get the mouse cursor position on the screen.

Here i.x.ax (say) means register A (16 bit).
and int86 calls with 0x33 as the interrupt number of the mouse service routine. It is multiplied by 4 to give the location of the ISR of mouse.

Avik.
0
 
LVL 1

Author Comment

by:ico2
ID: 10792934
avik77-that produces tons of errors with my compiler.

undefined symbols and invalid structures etc.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 2

Expert Comment

by:Avik77
ID: 10793017
>>how do i read a text file into a string?
u can do a character wise copy from ur text file to a string, or u can find the length of the input text file, and copy block to a string buffer using fread.

Avik.
0
 
LVL 2

Accepted Solution

by:
Avik77 earned 20 total points
ID: 10793076
>>avik77-that produces tons of errors with my compiler.
declare
union REGS i,o; // globally
and include dos.h

Avik.
0
 
LVL 1

Author Comment

by:ico2
ID: 10794109
ok i had to edit the code a bit to make it compile. but it works now. thanks very much.

thanks also to kdo but i can only credit one person.
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question