Thread: What's wrong with Micorsoft Visual C++?

  1. #1
    knave
    Guest

    Angry What's wrong with Micorsoft Visual C++?

    When I start a new project in the Microsoft Visual C++ compiler,
    win32 console, it can't compile things like:

    void locate(int col, int row)//Locate cursor at location on screen,
    { // Is this type of code only for DOS and not for
    // Win32 Console projects?????????
    union REGS regs;

    regs.h.ah=0x02;
    regs.h.bh=0x00;
    regs.h.dh=row;
    regs.h.dl=col;
    int86(VIDEO,&regs,&regs);
    }

    Why? I dont understand, it seems like the more stuff I learn that
    I can do with C++, is the more things I find that the Microsoft Visual C++ compiler can't do. I feel like im wasteing my time programming because im not getting anywhere, if i start a project, i will always end up with a brick wall in my face saying I can't do something because the Microsoft Visual C++ compiler
    doesn't support it, etc.

    Microsoft Visual C++
    -----------------------------------------------------------------------------------
    - where is the clearscreen function?
    - where is the function that can move the cursor around?
    - Why is it when you write C++ code and call a getch(),
    it skips all the code and starts from there first?
    - Is this the only way to color text in a win32 console project?
    SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    if it is, then damn, it sucks.
    -----------------------------------------------------------------------------------

    Can anyone help?
    Is there any documentation on win32 console mode projects?
    Where can I get a documentation on pdcurses?
    How can I compile things like whats above in MSVC++?

    My goal isn't to rip on the MSVC++ compiler, I just want to know
    how to use the screen when programming in win32 console, for instance, make a good user interface. How are interfaces like the "edit" program in DOS created(an interface with windows, etc)? I don't want to switch compilers either, i want to get good with one.

    I might get in trouble for asking more then one question in a post, but this is getting extremelt frustrating. If anyone can help,
    plz do.

    knave

  2. #2
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    You can not use VC++6 to directly access hardware unless your goal is to use the Win32 API. Microsoft operating systems are now sophisticated. The operatings system manages its own resources and also runs multiple processes at the same time. Your code is ancient chineese code, it will never work unless you get a computer from the 1980's and use it on that!

    You can clear the screen in MSVC++6 with
    Code:
    //clear screen
    system("cls");
    //do any command prompt opeation, for example
    system("copy f1 f2");
    Im MSVC++ getch now becomes
    Code:
    _getch();
    And yes you can do colors if you build an MFC project but you can not use those ancient commands such as textcolor(RED);, all that stuff has been obsolete for decades. Get a modern book!
    I compile code with:
    Visual Studio.NET beta2

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Gracious me, I agree with Dean, never thought the day would come!

    >>> Get a modern book!

    A poor second option would be to find a 16 bit compiler, look in the FAQ.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    here is the clear screen routine for msvc. written by sunlight that you would have found if you had looked in the faq.
    Code:
    void clrscr() 
    { 
    COORD coordScreen = { 0, 0 }; 
    DWORD cCharsWritten; 
    CONSOLE_SCREEN_BUFFER_INFO csbi; 
    DWORD dwConSize; 
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
    
    GetConsoleScreenBufferInfo(hConsole, &csbi); 
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y; 
    FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); 
    GetConsoleScreenBufferInfo(hConsole, &csbi); 
    FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); 
    SetConsoleCursorPosition(hConsole, coordScreen); 
    }
    here is the gotoxy function.
    Code:
    void gotoxy(int x, int y) 
    { 
    COORD point; 
    point.X = x; point.Y = y; 
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),point); 
    }
    you already know how to change text colour and background colour so write your own textcolour and bacground colour functions. That is simple enough to do.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    knave
    Guest

    Hi.

    I can't believe it. Everything worked perfect!

    Thanks Stone_Coder for the awesome functions, compiled
    perfectly and worked perfectly. I always thought I had to use a specific library to move the cursor around like that.

    Thanks Witch_King for letting me know how to use the _getch()
    in msvc++, compiled perfectly and worked perfectly.

    And btw - I was useing the system() function before, but I kept feeling like i was cheating my self.

    You guys are awesome! I don't know what else to say.

    Thanks.

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    101
    - where is the clearscreen function?
    - where is the function that can move the cursor around?
    The reason these functions are not in the C++ standard library is that as far as the standard is concernced, there may be no screen at all to clear or move the cursor about. You would have to ask Microsoft why they haven't included one of their own.
    - Why is it when you write C++ code and call a getch(), it skips all the code and starts from there first?
    Where'd you get that idea?
    - Is this the only way to color text in a win32 console project?
    SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    This is one of the ways. Since you have MSVC you must also have the MSDN CDs. Take a look at the following:
    Platform SDK->Windows Base Services->File and I/O->Consoles and Character-Mode Support
    Platform SDK->Reference->Code Samples->WINUI->CONSOLE
    Where can I get a documentation on pdcurses?
    This is a UNIX library.
    I feel like im wasteing my time programming because im not getting anywhere, if i start a project, i will always end up with a brick wall in my face saying I can't do something because the Microsoft Visual C++ compiler
    doesn't support it, etc.
    You are wasting your time if you're coding things like this. The problem is not the compiler, the problem is that the OS can't allow you such control over the hardware. There is hardly any reason at all to try to access it directly unless you're making a driver or something of the sort.
    - lmov

  7. #7
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Smile I agree

    I agree with lmov, MSVC is an exellent compiler... its meant for a sertin OS, and you are writing for another, MSVC doesnt support the DOS API... its not the compiler's fault... and as lmov said, there is no reason to.

    SPH.

    P.S. Learn the API you are programming for
    .

  8. #8
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102

    What are the adv. disadv. to using system("cls") as opposed to sunlightd's func??
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  9. #9
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    The reasons you should avoid the system() function are described in the FAQ.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  10. #10
    Registered User
    Join Date
    Aug 2001
    Posts
    154

    FAQ locations

    The problem with referring people to the FAQ is that there are more than one FAQ. The FAQ button at the top of the page takes you to an administrative FAQ with stuff like using smilies, posting avatars, etc. The programming FAQ is here:
    http://www.cprogramming.com/boardfaq.html
    and the FAQ the links on the message board pages (the administrative FAQ) is here:
    http://www.cprogramming.com/cboard/m...?s=&action=faq
    So if someone with a programming question just reads "Check the FAQ", and clicks on the FAQ button, chances are the anwer they want is not there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. whats wrong with visual studio?
    By Masterx in forum Tech Board
    Replies: 10
    Last Post: 06-21-2009, 12:28 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. visual c++... what did I do wrong?
    By shimojimatto in forum C++ Programming
    Replies: 5
    Last Post: 07-29-2007, 07:08 AM
  4. question about .net to 6.0 change causing errors
    By jverkoey in forum C++ Programming
    Replies: 17
    Last Post: 03-23-2004, 10:45 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM