Thread: fullscreening the dos window

  1. #1
    Registered User Ajsan's Avatar
    Join Date
    Dec 2003
    Posts
    55

    fullscreening the dos window

    i am trying to find code that will fullscreen the dos window...i know that its possible but i cant find the code....i'm moderatly sure that it sill involve including the windows.h include file.
    Style is overrated.

    - —₽‚¢‰Î -

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

  3. #3
    Registered User Ajsan's Avatar
    Join Date
    Dec 2003
    Posts
    55

    thx

    thx for the link
    Style is overrated.

    - —₽‚¢‰Î -

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Here's a little more robust version:
    Code:
    // Simulate ALT-ENTER keystrokes
    void AltEnter()
    {
        // NOTE: This method only works if the console window has the keyboard 
        //       focus and the user isn't hitting keys on the keyboard.
        SetForegroundWindow(GetConsoleWindow()); 
        keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0); 
        keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0); 
        keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0); 
        keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0); 
    }//AltEnter
    If you're running on an NT based verison of Windows, here is the best way to do it:
    Code:
    /*-----------------------------------------------------------------------------
    NT_SetConsoleDisplayMode - Set the console display to fullscreen or windowed.
    
    Parameters:
        hOutputHandle - Output handle of cosole, usually 
                            "GetStdHandle(STD_OUTPUT_HANDLE)"
        dwNewMode - 0=windowed, 1=fullscreen
    
    Returns Values: 
        TRUE if successful, otherwise FALSE is returned. Call GetLastError() for 
        extened information.
    
    Remarks:
        This only works on NT based versions of Windows.
    
        If dwNewMode is anything other than 0 or 1, FALSE is returned and 
        GetLastError() returns ERROR_INVALID_PARAMETER.
        
        If dwNewMode specfies the current mode, FALSE is returned and 
        GetLastError() returns ERROR_INVALID_PARAMETER. Use the (documented) 
        function GetConsoleDisplayMode() to determine the current display mode.
    -----------------------------------------------------------------------------*/
    BOOL NT_SetConsoleDisplayMode(HANDLE hOutputHandle, DWORD dwNewMode)
    {
        typedef BOOL (WINAPI *SCDMProc_t) (HANDLE, DWORD, LPDWORD);
        SCDMProc_t SetConsoleDisplayMode;
        HMODULE hKernel32;
        BOOL bFreeLib = FALSE, ret;
        const char KERNEL32_NAME[] = "kernel32.dll";
    
        hKernel32 = GetModuleHandleA(KERNEL32_NAME);
        if (hKernel32 == NULL)
        {
            hKernel32 = LoadLibraryA(KERNEL32_NAME);
            if (hKernel32 == NULL)
                return FALSE;
    
            bFreeLib = true;
        }//if
    
        SetConsoleDisplayMode = 
            (SCDMProc_t)GetProcAddress(hKernel32, "SetConsoleDisplayMode");
        if (SetConsoleDisplayMode == NULL)
        {
            SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
            ret = FALSE;
        }//if
        else
        {
            DWORD dummy;
            ret = SetConsoleDisplayMode(hOutputHandle, dwNewMode, &dummy);
        }//else
            
        if (bFreeLib)
            FreeLibrary(hKernel32);
    
        return ret;
    }//NT_SetConsoleDisplayMode
    adrianxw is more than welcome to clean this up and use it in his tutorials

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM