Win32 Console Application...Full Screen?

This is a discussion on Win32 Console Application...Full Screen? within the C++ Programming forums, part of the General Programming Boards category; Hello, I am writing a very simple Win32 Console Application. My question is this: How can I start the program ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Win32 Console Application...Full Screen?

    Hello, I am writing a very simple Win32 Console Application. My question is this: How can I start the program full screen? I know I can hit ALT+ENTER when the program is running and it will switch. I need my program to begin in full-screen though. I have heard that it is possible, but have not heard how. This is a code snippet from somewhere, but it still doesn't work. It flips full screen for a second then goes back to windowed.

    BOOL fullscreen;

    DEVMODE dmScreenSettings;
    memset(&dmScreenSettings,0,sizeof(dmScreenSettings ));
    dmScreenSettings.dmSize=sizeof(dmScreenSettings);
    dmScreenSettings.dmPelsWidth=width;
    dmScreenSettings.dmPelsHeight=height;
    dmScreenSettings.dmBitsPerPel=bits;
    dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWID TH|DM_PELSHEIGHT;

    if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLS CREEN)!=DISP_CHANGE_SUCCESSFUL) {
    if(MessageBox(NULL,"The requested fullscreen mode is not supported\nby your video card. use windowed mode instead?","HA HA!",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) {
    __asm int 3;
    fullscreen=FALSE;
    }
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    There's no documented way to do this....but here's a hack I did a while ago.....

    Code:
    bool GoFullScreen(void){
    	TCHAR strTitle[] = 
    		"If you can read this....The program was unable to maximise";
    	SetConsoleTitle(strTitle);//Set dummy name
    	hwnd = FindWindow(NULL,strTitle);//Locate window
    	if(hwnd != NULL){
    	int nVer = HIBYTE(LOWORD(GetVersion()));//Win 98 or 2K?
    	if(nVer != 0)//If 98
    	SendMessage(hwnd,WM_COMMAND,
    		57359,0);//Send maximise command
    	else
    	SendMessage(hwnd,WM_SYSKEYDOWN,
    		VK_RETURN,536870912);//Send alt-enter (Win2k)
    	}
    	return true;
    }
    It works ok with Win 2000 and I guess XP....but I couldnt get to work consistantly with Win95/98.......And as all my pc's are Win 2000 now....I cant finish it.....

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Talking

    yep, I'm using win2k for my team's game. Thank's a lot, it works great! Your our now my new HERO!

  4. #4
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Fordy, that function works in Win98 too. I changed this
    Code:
    TCHAR strTitle[] = "If you can read this....The program was unable to maximise";
    	SetConsoleTitle(strTitle);//Set dummy name
    	hwnd = FindWindow(NULL,strTitle);//Locate window
    into this:
    Code:
    	hwnd = FindWindow(NULL, "Menu");// where Menu is the name of my application
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    It did work...but not consistantly......that's why I gave the warning.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Taking Screenshot - Full Screen Dos
    By loko in forum C Programming
    Replies: 12
    Last Post: 07-16-2005, 01:23 AM
  2. icon in win32 console application
    By osal in forum Windows Programming
    Replies: 3
    Last Post: 06-30-2004, 02:13 PM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. confusion win32 -console app
    By GanglyLamb in forum C Programming
    Replies: 2
    Last Post: 06-11-2003, 10:12 AM

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