{steinsoft.net}
 
 
 
 
 
Home/News
Code Snippets
Board
Projects
What's That?
I am using it actively
I planning to use/learn it
I don't plan to lean/use it
5th option
Leipzig
Home :: Programming :: Code Snippets :: MfcWin :: Setting the Screenmode

[ Setting the Screenmode ]

Changing the displaymode is very easy. It's even easier with the class wrapper SScreenmode from the code section. I will show you how to do that using this little, helpful class.

First you have to get the above class. Then copy SScreenMode.h and SScreenMode.cpp to the directory where your project is. You could also copy the header file in the standard include dir of your IDE but I won't do it here. So lets quickly look at the code:

//Include the headerfile
#include "SScreenMode.h"
 
//*******
//GLOBALS
//*******
SScreenMode screenmode; //instance used later on

After including the headerfile and creating an instance of SScreenMode - either it's global or a member of another class - we are ready to do something. Remember that it is always better to set the screenmode before creating the main window. This prevents errors. Here is the windows creation function:

void CreateWindow()
{
   screenmode.setDisplayMode(640,480,16);
 
   //..
   //OTHER THINGS TO DO:
   // Window creation etc.
   //..
}

That's it! The screenmode will be changed to 640x480 with 16 colorbits. You now don't need to do anything more. The displaymode will be reset when the instance of SScreenmode is destroyed so when the application quits. If you explicitely want to reset the display mode, call screenmode.reset().

Questions? Suggestions? Anything else? M@il me or visit the message board. Happy Coding!

 Last edited 2002-12-08 00:58:51 by André Stein - printable version
» copyright by andré stein
» using stCM v1.0
» steinsoft.net revision 5.0