Thread: Problem with text cursor in C

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    6

    Problem with text cursor in C

    Hi all,
    sorry to trouble u all again,but its very urgent ..I had posted a question in this forum about setting the text cursor in a C program. I need to handle mouse in my C program and I am able to capture mouse and left click but I want to set the text cursor on the position I left-click on the screen so that I can read some values at that location by scanf().I am sending the program as attachment...please go thru it and advice me..The gotoxy() function to position the text cursor does not work at all...The message is getting printed where the mouse is clicked but is getting printed at position(0,0) of the screen. Earlier I was asked to use gotoxy() function as solution to this problem but it is not workig at all.I tried my best to solve it myself and I searched all over the Net but was not successful.. it is a student project and I have to submit it soon....thanks in advance

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    > setcursor(MouseX,MouseY);
    > clrscr();
    > gotoxy(MouseX,MouseY);
    Shouldn't this be:
    Code:
    			setcursor(mx, my);
    			clrscr();
    			gotoxy(mx, my);

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    It could be, but the global variables used (MouseX and MouseY) are set to that value too.
    Code:
    int mouseposition(int *x,int *y)
    {
    	int butt;
    	i.x.ax=0x3;
    	int86(0x33,&i,&o);
    	butt=o.x.bx;
    	*x=o.x.cx;
    	*y=o.x.dx;
    	MouseX=*x;
    	MouseY=*y;
    	return butt;
    }
    I don't see why you're doing this.
    Code:
     	mousept=startmouse();
    	mousept=viewmouse();
    The value from the first call is simply overwritten by the second call, and you don't use the variable after that anyway.

    Print the values of the parameters that you pass to gotoxy(). Make sure they aren't just both zero.

    it is a student project and I have to submit it soon
    Why is your teacher using such old code? That is using DOS interrupts etc.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >It could be, but the global variables used (MouseX and MouseY) are set to that value too.
    Good point. I completely missed that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GUI Text Color Problem
    By justlivelife15 in forum Windows Programming
    Replies: 3
    Last Post: 06-25-2007, 05:47 AM
  2. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  3. Problem drawing Rectangles and Text
    By cram in forum Windows Programming
    Replies: 2
    Last Post: 10-13-2004, 09:51 PM
  4. Problem parsing comments and such in text file
    By zaxxon in forum C Programming
    Replies: 3
    Last Post: 08-09-2004, 12:14 AM
  5. Text file manipulation problem
    By ferretman in forum C Programming
    Replies: 3
    Last Post: 12-20-2001, 02:40 AM