How to change screen resolution to 1024 x 600
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: How to change screen resolution to 1024 x 600

  1. #1
    Join Date
    Mar 2004
    Posts
    12

    How to change screen resolution to 1024 x 600

    Hi All,
    I know I can use ChangeDisplaySettings API to change screen
    resolution, but how to change this one "1024 x 600"
    Thanks

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352
    From MSDN:
    Remarks
    To ensure that the DEVMODE structure passed to ChangeDisplaySettings is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function.
    Does your device support this resolution (1024 x 600)?

  3. #3
    Join Date
    Nov 2001
    Location
    Kerala,India
    Posts
    650
    Code:
    
    bool _stdcall  SetResolution ( int nWidth,int nHeight,int nDepth )  {
    	DEVMODE Devmode;
    	int  iModeNum = 0;
    	if ( EnumDisplaySettings ( NULL,ENUM_CURRENT_SETTINGS, &Devmode ) ) {
    		 intScreenWidth  = Devmode.dmPelsWidth;
    		 intScreenHeight = Devmode.dmPelsHeight;
    		 intScreenDepth  = Devmode.dmBitsPerPel;
    	} else {
    		DisplayErrorText ( GetLastError ( ) );
    		return false;
    	}
    	while ( EnumDisplaySettings ( NULL,iModeNum++, &Devmode ) != 0 ) {
    		if ( Devmode.dmBitsPerPel== nDepth  &&
    			 Devmode.dmPelsWidth == nWidth  &&
    			 Devmode.dmPelsHeight== nHeight ) {
    			 Devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
    			 switch ( ChangeDisplaySettings ( &Devmode,
    				                            CDS_UPDATEREGISTRY ) ) {
    				case DISP_CHANGE_SUCCESSFUL:
    					return true;
    					break;
    				case DISP_CHANGE_BADMODE:
    					MessageBox ( GetDesktopWindow (),
    						         "The graphics mode"
    " is not supported.",
    						         "DllError" ,0 );
    					return false;
    					break;
    				case DISP_CHANGE_NOTUPDATED:
    					MessageBox ( GetDesktopWindow (),
    						         "Unable to write"
    "settings to the registry.",
    						         "DllError" ,0 );
    					return false;
    					break;
    				case DISP_CHANGE_RESTART:
    					MessageBox ( GetDesktopWindow (),
    						         "The computer must"
    " be restarted in order for the graphics mode to work.",
    						         "DllError" ,0 );
    					return true;
    					break;
    			 }
    		}
    	}
    	MessageBox ( GetDesktopWindow (),
    		         "The display driver failed the specified graphics mode.",
    		         "DllError" ,0 );
    	return false;
    }
    
    
    void DisplayErrorText ( DWORD dwLastError )   {
         HMODULE hModule = NULL;
         LPSTR MessageBuffer;
         DWORD dwBufferLength;
         DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
                               FORMAT_MESSAGE_IGNORE_INSERTS |
                               FORMAT_MESSAGE_FROM_SYSTEM ;
         if ( dwLastError >= NERR_BASE && dwLastError <= MAX_NERR ) {
              hModule = LoadLibraryEx ( TEXT("netmsg.dll"),NULL,
    			                        LOAD_LIBRARY_AS_DATAFILE );
            if ( hModule != NULL )
                dwFormatFlags |= FORMAT_MESSAGE_FROM_HMODULE;
         }
         if ( dwBufferLength = FormatMessageA ( dwFormatFlags,hModule,dwLastError,
                               MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ),
                               ( LPSTR ) &MessageBuffer, 0 , NULL ) )     {
    		 MessageBox ( GetDesktopWindow (),MessageBuffer, "DllError" ,0 );
             LocalFree  ( MessageBuffer );
         }
         if ( hModule != NULL )
              FreeLibrary ( hModule );
    }
    
    Try this funcionme
    Last edited by Mick; May 12th, 2004 at 08:39 PM.

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062
    Please use the code tags when you post such a bunch of code.

  5. #5
    Join Date
    Mar 2004
    Posts
    12
    Originally posted by Vinod S

    Try this funcion
    Hi Vinod,
    Thanks for your post,
    but I try it got "The graphics mode is not supported" message,
    how to force change this strange resolution 1024x600?

    Wesley

  6. #6
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    *sigh*

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352
    ...got "The graphics mode is not supported" message,
    how to force change this strange resolution 1024x600?
    Buy the monitor which supports "this strange resolution 1024x600"

    PS:
    Do you read the replies to your post?
    Do you ever read MSDN?

  8. #8
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    This is like saying to your PC 'please make me a nice cup of tea'.

    Not a great deal happens I think you'll find because the PC doesn't support it.

    How can you get the PC to do something that it doesn't support ? Surprisingly enough you can't.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352
    Buy the monitor which supports "this strange resolution 1024x600"
    Sorry, correction:
    probably, you only need some new video drivers (or video card), not a new monitor

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center