More console cursor problems...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: More console cursor problems...

  1. #1
    Eliza Guest

    More console cursor problems...


    Hi everyone.

    I'm sure I have read at least 20 solution suggestions as how to place the
    cursor/clear the screen in a Win 32 console app (and tried all of them).
    Nothing works for me. When I use system("cls"), nothing happens. When I use
    SetConsoleCursorPosition, it returns success, but nothing happens. I am seriously
    starting to consider the "ThrowMonitorOutWindow" option which I saw in another
    board or FAQ, but it has its obvious disadvantages. Can somebody please help
    before I do this...;)? Could the problem be that I'm using Win2K and the
    cosole is not DOS-based? I am totally lost here.

    //Eliza

  2. #2
    ralph Guest

    Re: More console cursor problems...


    I am using Win2k and the statement "system("cls")" works fine on my system.

    Assuming "cls" works when typed on the command line in a console windows,
    the only thing I can think of is the possiblility of getting bit by UNICODE
    and API calls. (pure fantasy)

    Trying compiling with the '_CONSOLE, _MBCS' options set.

  3. #3
    nomorsht Guest

    Re: More console cursor problems...


    "Eliza" <eliz@zadura.net> wrote:
    >
    >Hi everyone.
    >
    >I'm sure I have read at least 20 solution suggestions as how to place the
    >cursor/clear the screen in a Win 32 console app (and tried all of them).
    >Nothing works for me. When I use system("cls"), nothing happens. When I

    use
    >SetConsoleCursorPosition, it returns success, but nothing happens. I am

    seriously
    >starting to consider the "ThrowMonitorOutWindow" option which I saw in another
    >board or FAQ, but it has its obvious disadvantages. Can somebody please

    help
    >before I do this...;)? Could the problem be that I'm using Win2K and the
    >cosole is not DOS-based? I am totally lost here.
    >
    >//Eliza


    Eliza,

    If you post your code we might be better able to help you.

    nomorsht


  4. #4
    Eliza Guest

    Re: More console cursor problems...


    Thank you for your replies,

    I have finally managed to get system("cls") to do what it's supposed to.
    It seems it doesn't work when I use cin and cout, but if I use printf and
    scanf, it does the job. I don't know if I'm confusing things but I don't
    see why that would make a difference. (I do call _flushall before every call
    to system(), as suggested in MSDN). It's difficult to post the code I have
    been using with SetConsoleCursorPosition, since I have tried so many variations,
    but it's basically along these lines:

    void main(){
    COORD home = {0,0};
    DWORD err;
    BOOL success;

    HANDLE hConsoleOut;
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    if success(SetConsoleCursorPositon(hConsoleOut,home)
    //continue with main...
    else
    err = GetLastError();
    }


    "nomorsht" <nomorsht@hotmail.com> wrote:
    >
    >"Eliza" <eliz@zadura.net> wrote:
    >>
    >>Hi everyone.
    >>
    >>I'm sure I have read at least 20 solution suggestions as how to place the
    >>cursor/clear the screen in a Win 32 console app (and tried all of them).
    >>Nothing works for me. When I use system("cls"), nothing happens. When I

    >use
    >>SetConsoleCursorPosition, it returns success, but nothing happens. I am

    >seriously
    >>starting to consider the "ThrowMonitorOutWindow" option which I saw in

    another
    >>board or FAQ, but it has its obvious disadvantages. Can somebody please

    >help
    >>before I do this...;)? Could the problem be that I'm using Win2K and the
    >>cosole is not DOS-based? I am totally lost here.
    >>
    >>//Eliza

    >
    >Eliza,
    >
    >If you post your code we might be better able to help you.
    >
    >nomorsht
    >



  5. #5
    nomorsht Guest

    Re: More console cursor problems...


    Eliza,

    The sample below should work. SetConsoleCursorPosition doesn't
    have any effect if you are using "cout" to print with.

    #include <windows.h>
    #include <stdio.h>

    int main(void)
    {
    COORD home = {40,10};
    BOOL success;

    if( success = SetConsoleCursorPosition(GetStdHandle
    (STD_OUTPUT_HANDLE),home))
    printf("Hello World!!\n");
    return 0;
    }


    nomorsht

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center