home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- *
- * File : common.c
- *
- * Abstract : Some generally useful functions for Windows applications
- *
- **********************************************************************
- *
- * This file is a product of Criterion Software Ltd.
- *
- * This file is provided as is with no warranties of any kind and is
- * provided without any obligation on Criterion Software Ltd. or
- * Canon Inc. to assist in its use or modification.
- *
- * Criterion Software Ltd. will not, under any
- * circumstances, be liable for any lost revenue or other damages arising
- * from the use of this file.
- *
- * Copyright (c) 1995 Criterion Software Ltd.
- * All Rights Reserved.
- *
- * RenderWare is a trademark of Canon Inc.
- *
- ************************************************************************/
- #define INCLUDE_SHELLAPI_H
-
- #include <windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-
- #include <rwlib.h>
- #include <rwwin.h>
-
- /************************************************************************
- *
- * Function: AllowStretching()
- *
- * Description: Test whether to allow WinG or DIBSection stretching
- * for this application. The rules that are applied are
- * if WinG or DIBSection bitmaps are used AND we are
- * running in 8 bit then allow stretching. For all other
- * bitmap types and display depths disallow it.
- *
- * Return Value: TRUE if strecthing is allowed, FALSE otherwise
- *
- ************************************************************************/
- RwInt32 AllowStretching(HWND window)
- {
- RwInt32 Stretching = FALSE;
- DWORD version;
- int majorVersion;
- int minorVersion;
- HDC dc;
- int depth;
-
- /* find out the current display depth */
-
- dc = GetDC(window);
- depth = GetDeviceCaps(dc, BITSPIXEL);
- ReleaseDC(window, dc);
-
- if (depth == 8)
- {
- /* Check if we're using WING first */
-
- RwGetDeviceInfo(rwWINUSINGWING, &Stretching, sizeof(RwInt32));
-
- if (!Stretching) /* not enabled yet */
- {
- /* Find out which version of Windows we are running on */
-
- version = GetVersion();
- majorVersion = LOBYTE(LOWORD(version));
- minorVersion = HIBYTE(LOWORD(version));
-
- /* If we are on Windows 95 or NT 3.5 at this point then we must
- be using DibSections if native or DIBS otherwise */
-
- if ((majorVersion == 3) && (minorVersion < 95))
- {
- if (version < 0x80000000UL)
- {
- /* NT */
- #ifdef WIN32
- Stretching = TRUE;
- #else
- Stretching = FALSE;
- #endif
- }
- }
- else
- {
- /* Windows 95.*/
- #ifdef WIN32
- Stretching = TRUE;
- #else
- Stretching = FALSE;
- #endif
- }
- }
- }
- return(Stretching);
- }
- /************************************************************************
- *
- * Function: CheckDisplayDepth()
- *
- * Description: Check the depth of the display and pop up a
- * warning dialogue if it isn't one of the native
- * RenderWare depths.
- *
- * Parameters: window - The window for the calling application
- *
- * Return Value: The current display depth
- *
- ************************************************************************/
- int
- CheckDisplayDepth(HWND window)
- {
- HDC dc;
- int depth;
- char buffer[512];
-
- /*
- * Check the depth of the display. Although RenderWare will operate
- * correctly at all display depths it performs best when the display
- * depth is equal to one of its native render depths (8- or 16-bit).
- * If the display depth is not equal to one of these depths then
- * a message box is displayed recommending the depth of the display
- * is changed.
- */
- dc = GetDC(window);
- depth = GetDeviceCaps(dc, BITSPIXEL);
- ReleaseDC(window, dc);
- if ((depth != 8) && (depth != 16))
- {
- wsprintf(buffer,
- "Your video adapter is currently running in %ld color mode.\n"
- "Although RenderWare will operate correctly in this mode,\n"
- "we recommend that you change the mode of your video adapter\n"
- "to 256 color mode (for best performance) or 65536 color mode\n"
- "(for highest quality rendering).",
- (unsigned long)1 << depth);
- MessageBox(window, buffer, "RenderWare(tm) Application",
- MB_OK | MB_APPLMODAL | MB_ICONINFORMATION);
- }
- return (depth);
- }
-
-
-