Thread: changing dos screen

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    8

    changing dos screen

    i want to change the screen mode of dos to lines of 28 and cols of 80.
    the dos command for this is

    mode con lines=28 cols=80

    how do i do about doing this in C? this should be done before any displays are done.

    thanks in advance

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Get thee to MSDN.

    Edit: Here's a hint... check the console stuff, particularly the functions.
    Last edited by MacGyver; 07-05-2007 at 11:35 AM.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    i know the command that changes that..

    mode con lines=24 cols=80


    what i want to do is to do this exact command from C?


    should i be using system()..i tried this but cudn't get it doing..don't know system() function at all!!

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    system() is not your best alternative, but it might work for this. Using the functions from MSDN is more appropriate for most things, however, and something that is a little more guarenteed to work every time (and is much safer).

    If you are bent on using system(), why are you asking for ways to do it? Furthermore, how were you going about using it?

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    well the default dos screen has lines of 50 and cols of 80.
    now i am making a c project for college and the display in that screen height and size is not so good. i am doing it for lines of 32.
    now i can set this in the *.pif file and then run the pif file.
    i am asking if it is possible to do this without manually settting the pif file and running it from the program itself. (exe)
    the way to run the dos commands is thru system() ( i guess)
    so is this possible? and if how?

    thanks

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I already said it's possible by using the MSDN functions I linked to in my first post.

    Specifically:


  7. #7
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Ha...I'm loving this thread.
    nepdude: Tell me how.
    MacGyver: Here's a reference; figure it out.
    nepdude: No really, tell me how.
    MacGyver: Don't use system; read the reference.
    nepdude: Here's some more details. I don't want to read the reference. Tell me how.
    MacGyver: *gives in*
    Where's that head-banging smilie?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Nah, I didn't give in really.... Giving in would be to write out the solution for him like this:

    Code:
    void setSize(SHORT x, SHORT y)
    {
    	HANDLE hOut;
    	COORD cord;
    
    	cord.x = x; cord.y = y;
    	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    	if(hOut != INVALID_HANDLE_VALUE)
    	{
    		SetConsoleDisplayMode(hOut,CONSOLE_WINDOWED_MODE,cord);
    	}
    }
    Oh, wait.....


  9. #9
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    oopsi we are having some compiler version problem i guess.

    this is to be done in Turbo C++ 3.0 and yes no MSDN functions to be used at all..
    hope that clears the things up..if it were MSDN functions i would look and learn it..really not pushing u to spoon feed me the annswer ..just asking if it is possible or not..
    i tired this

    system("mode con lines=32 cols=80") and this ........ doesn't seem to be working.

  10. #10
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    So you're programming for DOS in 2007? Very nice. Ask your university/college to get with the times.

    There's a lot that is going on in the background, so I'll explain some of it, concluding with why your situation sucks.

    1. DOS compiled programs are different than Windows compiled programs.
    2. When you run "cmd" on Windows XP, you're really running a Windows program pretending to be a DOS program. It's not really DOS at all.
    3. When you compile a Windows console program, even though it's run in a DOS-like box, it's really a 32-bit Windows application.
    4. When you run a DOS compiled program on Windows, you end up with Windows pretending to be DOS. This means you have to write your DOS program to behave as if it's on DOS, and then hope that Windows knows how to understand it.
    5. Due to all the above, to bridge the gap between a DOS program and dealing with a Windows program..... Can you see why your situation sucks? You want to change functionality of a Windows program (ie. cmd.exe), via a DOS program. That won't happen.

  11. #11
    Registered User
    Join Date
    Jul 2007
    Posts
    8
    i am not getting any help here dude..yes it is ........ty that my college has us to do DOS stuffs..but they have done it so can't do nothing about it..

    well somebody else can help me here?

  12. #12
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Code:
    int i;
    for(i=0;i<1000;i++)
    {
    	quotePost("Can you see why your situation sucks?\
    		You want to change functionality of a Windows program (ie. cmd.exe),\
    		via a DOS program.  That won't happen.");
    }
    Edit the *.pif file like you mentioned. That's about the best I can think of with these ridiculous restrictions.

  13. #13
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by nepdude View Post
    i am not getting any help here dude..yes it is ........ty that my college has us to do DOS stuffs..but they have done it so can't do nothing about it..

    well somebody else can help me here?
    DOS had a lines command of 25, 43, and 50, iirc, but nothing in between that. If you're coercing something different out of cmd.exe and Windows, and that meets your needs, great.

    Leading immediately to the question "Do you ABSOLUTELY have to have 28 lines?" That sounds suspiciously arbitrary and perhaps capricious. Why not either cut down your display space to fit into the standard 25 lines, or jump up to 43 and add some appropriate extra blank lines to separate the info you're displaying?

    A few notes:

    1) This is no part of C - which is device independent for the most part. What you can set as your display parameters for a monitor is between your OS, your graphics display card, and your monitor, not C.

    2) I'd recommend going to a newsgroup like microsoft.windows.display or some such, for further info. They do have microsoft personnel there to answer questions (not every question gets answered, but most do), and see what they would recommend.

    I program occasionally with Turbo C, and if you go into your options menu, and into display, you'll see what it can support, there. Mine is version 2.0, and supports only 25, 43, or 50. I believe that is the same as your version will support.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How does this user get screen to run under root?
    By Overworked_PhD in forum Tech Board
    Replies: 2
    Last Post: 06-28-2009, 09:31 AM
  2. Linux Problem Screen Resoultion
    By Matus in forum Tech Board
    Replies: 1
    Last Post: 01-29-2009, 04:39 PM
  3. Changing screen colour
    By cc870 in forum C Programming
    Replies: 4
    Last Post: 07-01-2005, 07:12 AM
  4. Small VGA unit for DOS games
    By VirtualAce in forum Game Programming
    Replies: 1
    Last Post: 10-17-2003, 12:08 AM
  5. Full screen dos box?
    By Shadow in forum C Programming
    Replies: 8
    Last Post: 04-19-2002, 03:30 PM