Maximizing a Console Window Full Screen

This is a discussion on Maximizing a Console Window Full Screen within the Windows Programming forums, part of the Platform Specific Boards category; It works here, but it doesn't go to the far top-left corner (0,0). Instead its like 100, 100 for some ...

  1. #1
    Registered User philvaira's Avatar
    Join Date
    Apr 2004
    Posts
    72

    Maximizing a Console Window Full Screen

    It works here, but it doesn't go to the far top-left corner (0,0). Instead its like 100, 100 for some reason. I often have to move the window so it fits the full screen. Any advice is appreciated. Thanks.

    Code:
    #include <windows.h>
    #include <iostream>
    using namespace std;
    
    int main()
    {
        HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD NewSBSize = GetLargestConsoleWindowSize(hOut);
        SMALL_RECT DisplayArea = {0, 0, 0, 0};
    
        SetConsoleScreenBufferSize(hOut, NewSBSize);
    
        DisplayArea.Right = NewSBSize.X - 1;
        DisplayArea.Bottom = NewSBSize.Y - 1;
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    
        return 0;
    }
    Another way is to change the ALT+ENTER it does on its own here to max the window button. Any idea?

    Code:
    int main()
    {
      	HWND hWnd;
    	SetConsoleTitle("test");
    	hWnd = FindWindow(NULL,"test");
    	SendMessage(hWnd,WM_SYSKEYDOWN,
    			VK_RETURN,0xFF000000);
    
    	cout << "Hello World\n";
    	
    	return 0;
    Last edited by philvaira; 08-10-2004 at 05:18 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User philvaira's Avatar
    Join Date
    Apr 2004
    Posts
    72
    hehe Yeah I was there which came to the result of the code above. And I did some code on my own, and walla!! It's works now. w00t!

    Code:
    int main()
    {
       HWND hWnd;
       SetConsoleTitle("test");
       hWnd = FindWindow(NULL, "test");
        HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD NewSBSize = GetLargestConsoleWindowSize(hOut);
        SMALL_RECT DisplayArea = {0, 0, 0, 0};
    
        SetConsoleScreenBufferSize(hOut, NewSBSize);
    
        DisplayArea.Right = NewSBSize.X - 1;
        DisplayArea.Bottom = NewSBSize.Y - 1;
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    
    	ShowWindow(hWnd, SW_MAXIMIZE);
        return 0;
    }
    Share to the world.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    If you really want to go non-window'd full screen:
    fullscreening the dos window

    gg

  5. #5
    I'm less than sure.... abyssphobia's Avatar
    Join Date
    Aug 2004
    Posts
    112
    c:\numbers.cpp(43) : error C2065: 'HWND' : undeclared identifier
    c:\numbers.cpp(43) : error C2146: syntax error : missing ';' before identifier 'hWnd'
    c:\numbers.cpp(43) : error C2065: 'hWnd' : undeclared identifier
    c:\numbers.cpp(44) : error C2065: 'SetConsoleTitle' : undeclared identifier
    c:\numbers.cpp(45) : error C2065: 'FindWindow' : undeclared identifier
    c:\numbers.cpp(45) : error C2065: 'NULL' : undeclared identifier
    c:\numbers.cpp(46) : error C2065: 'HANDLE' : undeclared identifier
    c:\numbers.cpp(46) : error C2146: syntax error : missing ';' before identifier 'hOut'
    c:\numbers.cpp(46) : error C2065: 'hOut' : undeclared identifier
    c:\numbers.cpp(46) : error C2065: 'GetStdHandle' : undeclared identifier
    c:\numbers.cpp(46) : error C2065: 'STD_OUTPUT_HANDLE' : undeclared identifier
    c:\numbers.cpp(47) : error C2065: 'COORD' : undeclared identifier
    c:\numbers.cpp(47) : error C2146: syntax error : missing ';' before identifier 'NewSBSize'
    c:\numbers.cpp(47) : error C2065: 'NewSBSize' : undeclared identifier
    c:\numbers.cpp(47) : error C2065: 'GetLargestConsoleWindowSize' : undeclared identifier
    c:\numbers.cpp(48) : error C2065: 'SMALL_RECT' : undeclared identifier
    c:\numbers.cpp(48) : error C2146: syntax error : missing ';' before identifier 'DisplayArea'
    c:\numbers.cpp(48) : error C2065: 'DisplayArea' : undeclared identifier
    c:\numbers.cpp(48) : error C2059: syntax error : '{'
    c:\numbers.cpp(48) : error C2143: syntax error : missing ';' before '{'
    c:\numbers.cpp(48) : error C2143: syntax error : missing ';' before '}'
    c:\numbers.cpp(50) : error C2065: 'SetConsoleScreenBufferSize' : undeclared identifier
    c:\numbers.cpp(52) : error C2228: left of '.Right' must have class/struct/union type
    c:\numbers.cpp(52) : error C2228: left of '.X' must have class/struct/union type
    c:\numbers.cpp(53) : error C2228: left of '.Bottom' must have class/struct/union type
    c:\numbers.cpp(53) : error C2228: left of '.Y' must have class/struct/union type
    c:\numbers.cpp(55) : error C2065: 'SetConsoleWindowInfo' : undeclared identifier
    c:\numbers.cpp(55) : error C2065: 'TRUE' : undeclared identifier
    c:\numbers.cpp(57) : error C2065: 'ShowWindow' : undeclared identifier
    c:\numbers.cpp(57) : error C2065: 'SW_MAXIMIZE' : undeclared identifier
    Error executing cl.exe.
    lots of errors runing this code
    int main()
    {
    HWND hWnd;
    SetConsoleTitle("test");
    hWnd = FindWindow(NULL, "test");
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD NewSBSize = GetLargestConsoleWindowSize(hOut);
    SMALL_RECT DisplayArea = {0, 0, 0, 0};

    SetConsoleScreenBufferSize(hOut, NewSBSize);

    DisplayArea.Right = NewSBSize.X - 1;
    DisplayArea.Bottom = NewSBSize.Y - 1;

    SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);

    ShowWindow(hWnd, SW_MAXIMIZE);
    return 0;
    }
    mmmm let see.

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    Did you remember to include windows.h?

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    use code tags abyssphobia
    << !! Posting Code? Read this First !! >>

  8. #8
    I'm less than sure.... abyssphobia's Avatar
    Join Date
    Aug 2004
    Posts
    112
    Princeton u r my idol, thats right I forgot put
    # include<windows.h>
    thx again,
    well ok, its my way to learn, making disasters, hahaha
    ok =)

  9. #9
    Registered User philvaira's Avatar
    Join Date
    Apr 2004
    Posts
    72
    Yeah, I'm just too lazy to type it in.

  10. #10
    1479
    Join Date
    Aug 2003
    Posts
    253

    I tried that once.

    I tried to do that once. After reading adrianx's site I made a program that would come up in the normal size console window and I output "Please Press Alt + Enter" on the screen. After they pressed them the rest of the program would follow. The only problem with that was I ran into to problem that adrian stated. None of the keys on my keyboard worked correctly and I have to reboot.

    Thanks for this fantastic peice of code!!!!
    Knowledge is power and I want it all

    -0RealityFusion0-

  11. #11
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    philvaira:

    Can you tell me which version of Windows you are using, and if you used the code from my site unmodified?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Window scrollbar
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2005, 12:31 PM
  2. Output to console window...
    By alvifarooq in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2004, 08:56 PM
  3. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  4. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21