add: close button enabled

This commit is contained in:
Brian Matzon 2003-02-08 23:01:58 +00:00
parent 15b6e08872
commit 9a9406dc7e
3 changed files with 18 additions and 7 deletions

View File

@ -58,6 +58,9 @@ public final class Display {
/** A pointer to the native display window. On Windows this will be an hWnd. */ /** A pointer to the native display window. On Windows this will be an hWnd. */
private static int handle; private static int handle;
/** Whether or not the display has been requested to shutdown by the user */
public static boolean closeRequested = false;
/** /**
* No construction allowed. * No construction allowed.
*/ */
@ -214,5 +217,4 @@ public final class Display {
* @return true if the display is minimized * @return true if the display is minimized
*/ */
public static native boolean isMinimized(); public static native boolean isMinimized();
} }

View File

@ -11,6 +11,7 @@ extern "C" {
/* Inaccessible static: created */ /* Inaccessible static: created */
/* Inaccessible static: mode */ /* Inaccessible static: mode */
/* Inaccessible static: handle */ /* Inaccessible static: handle */
/* Inaccessible static: closeRequested */
/* Inaccessible static: class_000240 */ /* Inaccessible static: class_000240 */
/* /*
* Class: org_lwjgl_Display * Class: org_lwjgl_Display
@ -44,7 +45,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_nDestroy
JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_isMinimized JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_isMinimized
(JNIEnv *, jclass); (JNIEnv *, jclass);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -59,6 +59,9 @@ HDC hdc = NULL; // Device context
LPDIRECTINPUT lpdi = NULL; LPDIRECTINPUT lpdi = NULL;
bool isMinimized = false; bool isMinimized = false;
bool isFullscreen = false; bool isFullscreen = false;
JNIEnv* environment;
jclass clsDisplay;
jfieldID fidclose;
void destroyDI(void) void destroyDI(void)
{ {
@ -148,6 +151,12 @@ LRESULT CALLBACK WindowProc(HWND hWnd,
case SC_RESTORE: case SC_RESTORE:
isMinimized = false; isMinimized = false;
appActivate(false); appActivate(false);
break;
case SC_CLOSE:
environment->SetStaticBooleanField(clsDisplay, fidclose, true);
//don't continue processing this command since this
//would shutdown the window, which the application might not want to
return 0L;
default: default:
break; break;
} }
@ -276,6 +285,10 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
(JNIEnv * env, jclass clazz, jint width, jint height, jint bpp, jint freq, (JNIEnv * env, jclass clazz, jint width, jint height, jint bpp, jint freq,
jint alphaBits, jint depthBits, jint stencilBits, jboolean fullscreen, jstring title) jint alphaBits, jint depthBits, jint stencilBits, jboolean fullscreen, jstring title)
{ {
environment = env;
clsDisplay = clazz;
fidclose = env->GetStaticFieldID(clsDisplay, "closeRequested", "Z");
#ifdef _DEBUG #ifdef _DEBUG
printf("Creating display: size %dx%d %dhz %dbpp...\n", width, height, freq, bpp); printf("Creating display: size %dx%d %dhz %dbpp...\n", width, height, freq, bpp);
#endif #endif
@ -352,10 +365,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
NULL); NULL);
env->ReleaseStringUTFChars(title, titleString); env->ReleaseStringUTFChars(title, titleString);
// Disable close button
HMENU SysMen = GetSystemMenu(hwnd, false);
EnableMenuItem(SysMen, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED);
// And we never look at windowClass again... // And we never look at windowClass again...
ShowWindow(hwnd, SW_SHOWNORMAL); ShowWindow(hwnd, SW_SHOWNORMAL);