Advertisement

Why i can't make a full screen?

Started by April 12, 2005 02:04 AM
5 comments, last by Kiput 19 years, 10 months ago
I make a programme with BCB and want to make a full screen,but get a mistake : "The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?" I don't know why the programme jump to this point.And i want to know the truth of full screen.Is this line "ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)" the main function to make full screen? [pig]I'm a beginner and will appreciate very much your help!
   
void __fastcall TMainForm::ToolButton7Click(TObject *Sender)
{
   fullscreen=true;
   if(MessageBox(NULL,"Would you like to run in fullscreen mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION) == IDNO)
   {
      fullscreen = false;       // Windowed mode
   }

   if(fullscreen)
           {
              DEVMODE dmScreenSettings;
              memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
              dmScreenSettings.dmSize         = sizeof(dmScreenSettings);
              dmScreenSettings.dmPelsWidth    = ClientWidth;
              dmScreenSettings.dmPelsHeight   = ClientHeight;
              dmScreenSettings.dmBitsPerPel   = 24;
              dmScreenSettings.dmFields       = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

   if(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
      {
      if(MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","Nehe",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
         {
            fullscreen=false; 
         }
         else
         {
            MessageBox(NULL,"Program Will NowClose.","ERROR",MB_OK|MB_ICONSTOP);
            FormDestroy(MainForm);
         }

      }
ShowCursor(FALSE);
}

I don't see any obvious errors, but 24 bit color depth is probably not supported by any current video card. It's awful to handle since 3 bytes is such an odd number and requires two write instructions unless the video card manufacturer would specially provide 3 byte reads and writes for its rasterizer and blitting unit.

Try 32 bits, if it still doesn't work, report back here ;)

-Markus-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.
Advertisement
Thanks for your answer!
I do it as you said.Unfortunately it doesn't work.What is the matter of it?
And i want to know what's the meaning of this sentence"It's awful to handle since 3 bytes is such an odd number and requires two write instructions" .
The viedo card today does not support 24 bits color? I only know that 24 bits color contain R-8 bits,G-8 bits and B-8 bits.If you can explain more about it,i will appreciate you.
Thank you!
You are a German?Yesterday night i saw the game of FC Bayern Muenchen VS Chelsea.Have you ever seen it?I feel very disappointed and the second goal of Chelsea make me very sadness.I admire the spirit of Bayern,Although they have been eliminated from the game.
Wow, you get euro soccer matches in China. That did suprise me!
Btw, its best to use EnumDisplaySettings() to fill out the DEVMDODE structure - I had this problem before, windows seems to be a bit picky on how the fields of DEVMODE are filled. Keep enumerating until you find the required mode and use the returned DEVMODE structure to pass to ChangeDisplaySettings(), if the mode doesn't exist you can return an error to the user.

bool setDisplayMode(int width, int height, int minDepth){  // Structure for mode info  DEVMODE  mode;                                          // Enumerate display modes  for(int i = 0; EnumDisplaySettings(0, i, &mode); i++)  {    // If the colour depth is greater than minDepth and the    // mode can be changed without a restart continue to    // process the returned mode    if(mode.dmPelsHeight == height && mode.dmPelsWidth == width && mode.dmBitsPerPel > minDepth)    {      // Change the display mode      return(DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(0, &mode, 0, CDS_FULLSCREEN, 0));    }  }  // Throw error if a mode was not found  return(true);}




-arm.
Arm,This surprised you? Ha,it's all in the day's work.In your mind ,China is still behind the times?I believe you has dropped behind.Have a joke.[totally]
Thank you for you help.
I modified the programme like this:
DEVMODE dmScreenSettings;memset(&dmScreenSettings,0,sizeof(dmScreenSettings));dmScreenSettings.dmSize         = sizeof(dmScreenSettings);dmScreenSettings.dmPelsWidth    = ClientWidth;dmScreenSettings.dmPelsHeight   = ClientHeight;dmScreenSettings.dmBitsPerPel   = 32;dmScreenSettings.dmFields       = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;for(int i = 0; EnumDisplaySettings(0, i, &dmScreenSettings); i++){      if(ChangeDisplaySettingsEx(0,&dmScreenSettings,0,CDS_FULLSCREEN,0)!=DISP_CHANGE_SUCCESSFUL)         {             if(MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)               {                   fullscreen=false;                }            else               {                   MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);                         FormDestroy(MainForm);               }         }}

When I run it ,the screen flash several times every a few seconds.And finally it still give the information "The Requested¡­¡­Instead?"
But I use Nehe's code no modifiedd and sccceed.
Wish your help.Thanks for advance.

Advertisement
Add "else break" after that if and it'll work.

This topic is closed to new replies.

Advertisement