-
May 12th, 2004, 04:53 AM
#1
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
-
May 12th, 2004, 05:56 AM
#2
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)?
-
May 12th, 2004, 07:55 AM
#3
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.
-
May 12th, 2004, 08:59 AM
#4
Please use the code tags when you post such a bunch of code.
-
May 12th, 2004, 08:31 PM
#5
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
-
May 12th, 2004, 08:39 PM
#6
-
May 13th, 2004, 02:43 AM
#7
...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?
-
May 13th, 2004, 08:07 AM
#8
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.
-
May 13th, 2004, 08:25 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|