Console window size
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Console window size

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    3

    Lightbulb Console window size

    Hello all C++ guru's! I'm a student and I have a project in C++ B now.

    I'm wondering if it's possible to change the size of a cmd / comman prompt / console window from within a program?
    If you build a program and start it, you can right-click and choose properties and layout and there change the window size.

    Are there any ways to do this internally? Thanks!

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Console window size

    I am afraid to say that no one does that kind of console programming these days.

    The options you are mentioning are applicable till Windows 2000. Starting with Windows XP, choosing those console options are no longer valid.

    Furthermore, with Windows Vista and higher, you may not be able to full screen the console.

    ~ My condolences ~
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,546

    Re: Console window size

    Quote Originally Posted by possemannen View Post
    I'm wondering if it's possible to change the size of a cmd / comman prompt / console window from within a program?
    If you build a program and start it, you can right-click and choose properties and layout and there change the window size.

    Are there any ways to do this internally? Thanks!
    On Windows?
    Check out SetConsoleWindowInfo Function.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

  4. #4
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Console window size

    I was about to refer those console APIs, but since he has already classified him as a student I did not!
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  5. #5
    Join Date
    May 2010
    Posts
    3

    Re: Console window size

    Thanks for answers, but that doesn't seem to be just it. You know, standard character height is what? 8x6 pixels? But you can change that to something else and that's what I want to do from within my program. But maybe I'll figure out a way...

  6. #6
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Console window size

    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  7. #7
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Console window size

    That function requires Windows Vista/2008 as minimum.

    See Console functions.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  8. #8
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Console window size

    Yes i know, there is no documented way to do it pre-vista, however in kernal32.dll is undocumented SetConsoleFont( HANDLE, DWORD) that could be used but its not so easy to find information about undocumented functions.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  9. #9
    Join Date
    May 2010
    Posts
    3

    Re: Console window size

    Wow, that's a nice link! Thanks guys!
    What happens if I compile in vista and then runs the exe on xp?

    And can someone please post a simple example of SetCurrentConsoleFontEx function?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center