Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 16-10-2008, 12:29 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Dec 2007
Location: Bhopal, MP, India
Posts: 3
Default c++ help needed


I wanted know if there's a way in c++ to know what character exists at a particular x,y coordinate.
for eg: suppose i used gotoxy(2,5) and my cursor is now at (2,5) and i want to know what character exists next to my cursor at (3,5). How can i know that?
masterovpuppetz is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 17-10-2008, 02:20 AM   #2 (permalink)
Legen-wait for it-dary!
 
dheeraj_kumar's Avatar
 
Join Date: Dec 2004
Location: Chennai
Posts: 2,471
Default Re: c++ help needed

The screen is an output device, its for echoing the data in the memory. You cant read from the output device. What exactly are you trying to do? We can suggest alternatives for that.
__________________
If the Start Windows Restart when Windows starts check box is checked Windows Restart will start automatically every time Windows is started. - Actual excerpt from a windows program help file
dheeraj_kumar is offline  
Old 17-10-2008, 02:16 PM   #3 (permalink)
Broken In
 
Join Date: Oct 2008
Posts: 133
Default Re: c++ help needed

Quote:
Originally Posted by masterovpuppetz View Post
I wanted know if there's a way in c++ to know what character exists at a particular x,y coordinate.
for eg: suppose i used gotoxy(2,5) and my cursor is now at (2,5) and i want to know what character exists next to my cursor at (3,5). How can i know that?
well you can do it if you are in Win98 by directly accessing the video ram buffer located at 0xB8000, in physical memory. The buffer is of the datatype 'short', Each 16-bit element in the text memory buffer is broken into an 'upper' 8-bits and a 'lower' 8-bits. The lower 8 bits of each element tells the display controller what character to draw on the screen. We just have to extract this lower byte

use the following code

Code:
index = (y_value_cur * width_of_screen) + x_value_cur;
unsigned short *where = (unsigned short *)0xB8000 + index;
this code will give you direct access to the location where your cursor is

now to move to next or previous position just increment or decrement the where pointer .
lucifer_is_back is offline  
Old 17-10-2008, 06:50 PM   #4 (permalink)
Right Off the Assembly Line
 
Join Date: Dec 2007
Location: Bhopal, MP, India
Posts: 3
Default Re: c++ help needed

Thnx for the replies .I figured out a way to get the job done.
masterovpuppetz is offline  
Old 17-10-2008, 07:43 PM   #5 (permalink)
Broken In
 
Join Date: Oct 2008
Posts: 133
Default Re: c++ help needed

Quote:
Originally Posted by masterovpuppetz View Post
Thnx for the replies .I figured out a way to get the job done.
please share the code bro
lucifer_is_back is offline  
Old 19-10-2008, 10:00 PM   #6 (permalink)
Right Off the Assembly Line
 
Join Date: Dec 2007
Location: Bhopal, MP, India
Posts: 3
Default Re: c++ help needed

as u guys said tht it was not possible to get input from buffer screen using standard c++,i modified my code (infact had to reprogram about two thirds of it).

So now instead of getting the x,y coordinates during runtime, I have made a array of x,y coordinates( which holds the desired character) and check wether the cursor coordinates is next to ne of these predefined coordinates.

Not the best way to do the job i guess, but at least the program is working !!
masterovpuppetz is offline  
Old 19-10-2008, 10:46 PM   #7 (permalink)
Legen-wait for it-dary!
 
dheeraj_kumar's Avatar
 
Join Date: Dec 2004
Location: Chennai
Posts: 2,471
Default Re: c++ help needed

^^ Yeah, thats probably the best way.
__________________
If the Start Windows Restart when Windows starts check box is checked Windows Restart will start automatically every time Windows is started. - Actual excerpt from a windows program help file
dheeraj_kumar is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help needed!!! Zangetsu QnA (read only) 7 05-03-2008 05:09 PM
Help needed. Things needed to connect SATA HDD to... prashantmaxsteel Hardware Q&A 3 21-11-2007 12:26 PM
needed 2 buy a good camera????? help needed.. The Day Walker! Cameras and camcorders 5 02-07-2005 04:43 PM

 
Latest Threads
- by Sujeet
- by gforz
- by soumya

Advertisement




All times are GMT +5.5. The time now is 03:15 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2