Archived

This topic is now archived and is closed to further replies.

Koobazaur

Win32 Application - error with the GameTutorials "fullscreen" tutorial?

Recommended Posts

Koobazaur    1264
OK, so I''m learning Win32 reading GameTutorial tutorials and their fullscreen tutorial... well here''s the full code:
#include <windows.h>										// We need to include windows.h

#include <stdio.h>											// Include stdio.h for the basics


void ChangeToFullScreen(int width, int height)
{
	DEVMODE dmSettings;									// Device Mode variable - Needed to change modes


	memset(&dmSettings,0,sizeof(dmSettings));			// Makes Sure Memory''s Cleared


	// Get current settings -- This function fills our the settings

	// This makes sure NT and Win98 machines change correctly


	if(!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dmSettings))
	{
		// Display error message if we couldn''t get display settings

		MessageBox(NULL, "Could Not Enum Display Settings", "Error", MB_OK);
		return;
	}

	dmSettings.dmPelsWidth	= width;					// Set the desired Screen Width

	dmSettings.dmPelsHeight	= height;					// Set the desired Screen Height

	dmSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;	// Set the flags saying we''re changing the Screen Width and Height


	// This function actually changes the screen to full screen

	// CDS_FULLSCREEN Gets Rid Of Start Bar.

	// We always want to get a result from this function to check if we failed

	int result = ChangeDisplaySettings(&dmSettings,CDS_FULLSCREEN);

	// Check if we didn''t recieved a good return message From the function

	if(result != DISP_CHANGE_SUCCESSFUL)
	{
		// Display the error message and quit the program

		MessageBox(NULL, "Display Mode Not Compatible", "Error", MB_OK);
		PostQuitMessage(0);
	}
But I have a problem with this function:
!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dmSettings)
 
Compiler Error (Borland C++ 5.02): Error: fullscreen.cpp(60,53):Undefined symbol ''ENUM_CURRENT_SETTINGS'' I saw a note at the end of the tutorial saying that if I have win95 I should use this code instead:
void ChangeToFullScreen(int width, int height)
{
	DEVMODE devmode = {0};

		devmode.dmSize = sizeof(DEVMODE);
		devmode.dmPelsWidth	= width;
		devmode.dmPelsHeight = height;
		devmode.dmBitsPerPel = 16; // Bits per pixel

		devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

		if(ChangeDisplaySettings(&devmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
		{
			// Display the error message and quit the program

			MessageBox(NULL, "Display Mode Not Compatible", "Error", MB_OK);
			PostQuitMessage(0);
		}

}
I tried it and it compiles fine! But... I have win 98 SE ... So, why am I missing the ENUM_CURRENT_SETTINGS definition???

Share this post


Link to post
Share on other sites
Jason Doucette    122
From the MSDN page for EnumDisplaySettings, it looks like ENUM_CURRENT_SETTINGS is only for use on systems greater than Win95. You probably should check out the Using the SDK Headers MSDN page. It explains which macro you need to define to change the target platform, so you have access to target specific constants, such as the one you''d like to use.

Jason Doucette
Programming Windows, 5th Edition by Charles Petzold, Errata Addendum
projects / games | real-time graphics | artificial intelligence | world records | wallpapers / desktops / backgrounds
"Great minds discuss ideas, average minds discuss events, small minds discuss people." - Anna Eleanor Roosevelt, 1884-1962

Share this post


Link to post
Share on other sites