This is how to get your program to run fullscreen (console)

This is a discussion on This is how to get your program to run fullscreen (console) within the Windows Programming forums, part of the Platform Specific Boards category; EDIT: This edit is here because major small wanted me to point this out. This is a WINDOWS OS specific ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    Exclamation This is how to get your program to run fullscreen (console)

    EDIT: This edit is here because major small wanted me to point this out. This is a WINDOWS OS specific function (givin away by #include <windows.h>. So I would reccomend not using this program for anything other than personal use programs. If any one else has any other better ways of fullscreening let me know.



    Ok, alot of people I have noticed want to know how to get thier program to run in fullscreen right when you execute it so here is how
    Code:
    #include <iostream>
    #include <windows.h>
     
    using namespace std;
    //This Initiates the fullscreen function
    void fullscreen()
    {
    keybd_event(VK_MENU,0x38,0,0);
    keybd_event(VK_RETURN,0x1c,0,0);
    keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
    keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
    }
    //Below is where you would place your normal programming code.
    int main()
    {
    	fullscreen(); //This puts the window in fullscreen
    	cout << "Hello, See It Is Fullscreen.";
    	cin.get();
    	return 0;
    }
    Also note that to get back to your normal window just use the
    Code:
    fullscreen();
    function again. This little function has helped me alot for my porgramming. (instead of stretching the window to the resolution of your system.) This way no matter what computer you are using the program in it ALMOST always fits the screen perfectly.
    Last edited by Raigne; 11-24-2005 at 04:26 PM.

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by Raigne
    This way no matter what computer you are using the program in it ALMOST always fits the screen perfectly.
    thanks for posting non-standard code in the C++ board. I thought the #include <windows.h> would be a dead giveaway that it's not portable, but I guess not.

    the answer is: THERE IS NO PORTABLE WAY TO MAKE YOUR PROGRAM FULLSCREEN.

    if your code is going to be compiled ONLY on windows or ONLY on linux, go for a non-portable solution, but otherwise, you're stuck.

    I'm being a little harsh here, because you didn't even mention that it wasn't portable (or did you not know that?). You just gave it out like it was the solution to all our problems. what if somebody had always used that in all their programs, and then they get to a competition that runs a linux live CD as their OS (like ACM competitions)?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Let me try to be as nice as possible about this. Yes I did know that it is a non standard solution. Dont most programs(software) have sytem requirements? So basicly you made a command that doesnt allow installing OR using your program without the proper Operating System. So for the record
    PLEASE NOTE: That this is a non-standard function usable by WINDOWS Operating systems
    only. This is not a protable way to make your program fullscreen. and is limited to WINDOWS users. also note that this function will not work on window 98 or older.

    And another thing there is another way to make your fullscreening portable, but it has a tendency to suck up memory so I am not going to list it. Cuzz who wants a fullscreen function that causes your main program to not be able to run due to lack of resources. Well for people that have this holiday Happy Thanksgiving and for those who dont have a good day.

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    no, but the point is that this is the C++ board, where standard, portable code is highly regarded. That would be better posted in the windows programming boards, where most of those people already know how they could make a fullscreen app anyway.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    The problem is if you run this from a full screen command prompt.

  6. #6
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    ::SetConsoleDisplayMode(..) is certainly a bit less hackish than simulating the key sequence at the very least.

  7. #7
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Yes, didn't we have a thread EXACTLY like this but using a bit better method? Please do a search before posting a thread, it will decrease the chance of flamage. Oh btw, good to see you posting again Tonto.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,656
    And verily, the thread was made OS specific - and it was good.

  9. #9
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> is certainly a bit less hackish than simulating the key sequence at the very least.

    The reason part 6 of my console tutorial still uses this "hack" is because it works from Windows 95 ->. I point out that the function is deprecated, but after substantial research, I have not found a better way of doing this which works across all the platforms I support.

    SetConsoleDisplayMode() requires XP->. I could use GetVersion() and then run an appropriate function, but at this time, this works.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  10. #10
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Raigne
    Let me try to be as nice as possible about this. Yes I did know that it is a non standard solution. Dont most programs(software) have sytem requirements? So basicly you made a command that doesnt allow installing OR using your program without the proper Operating System. So for the record
    PLEASE NOTE: That this is a non-standard function usable by WINDOWS Operating systems
    only. This is not a protable way to make your program fullscreen. and is limited to WINDOWS users. also note that this function will not work on window 98 or older.

    And another thing there is another way to make your fullscreening portable, but it has a tendency to suck up memory so I am not going to list it. Cuzz who wants a fullscreen function that causes your main program to not be able to run due to lack of resources. Well for people that have this holiday Happy Thanksgiving and for those who dont have a good day.
    All Windows Console functions are limited to WINDOWS!

  11. #11
    Registered User
    Join Date
    Mar 2005
    Posts
    135
    The fact that he posted this thread in the C++ board is nothing to go off about. A lot of people new to C++ who are restricted to only programming in DOS want to know how to set the window full screen. They dont know anything about "Windows Programming" or what an API is so they ask a relevant question in the C++ board first - whatever their needs might be.

    9 times out of 10, newbies start off programming in Windows. Not linux, not OSX or some other operating system. So the bottom line is this, which you can disagree to or not, I don't care; It was all right for him to start this thread here, regardless of the function in quesion is portable or not. It would've been nice if he had *specifically* mention it's non-portable, but like I said, most people, like the OP, are mainly concerned about Windows. Only. So this thread benefits a wider audience for now, and for future reference.

  12. #12
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Enough moaning now. If people have any more to say about the technique fine, any more gripes and I'll delete them.
    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. MSVC++2008 console program portability
    By CodeMonkey in forum Windows Programming
    Replies: 1
    Last Post: 11-18-2008, 02:13 AM
  2. Help me with my basic program, nothing I create will run
    By Ravens'sWrath in forum C Programming
    Replies: 31
    Last Post: 05-13-2007, 02:35 AM
  3. Replies: 2
    Last Post: 12-22-2006, 07:45 PM
  4. plz help me run this program!!!
    By galmca in forum C Programming
    Replies: 8
    Last Post: 02-01-2005, 12:00 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 09:19 AM

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