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

@ -57,6 +57,9 @@ public final class Display {
/** A pointer to the native display window. On Windows this will be an hWnd. */
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.
@ -214,5 +217,4 @@ public final class Display {
* @return true if the display is minimized
*/
public static native boolean isMinimized();
}
}

View File

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

View File

@ -59,6 +59,9 @@ HDC hdc = NULL; // Device context
LPDIRECTINPUT lpdi = NULL;
bool isMinimized = false;
bool isFullscreen = false;
JNIEnv* environment;
jclass clsDisplay;
jfieldID fidclose;
void destroyDI(void)
{
@ -148,6 +151,12 @@ LRESULT CALLBACK WindowProc(HWND hWnd,
case SC_RESTORE:
isMinimized = 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:
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,
jint alphaBits, jint depthBits, jint stencilBits, jboolean fullscreen, jstring title)
{
environment = env;
clsDisplay = clazz;
fidclose = env->GetStaticFieldID(clsDisplay, "closeRequested", "Z");
#ifdef _DEBUG
printf("Creating display: size %dx%d %dhz %dbpp...\n", width, height, freq, bpp);
#endif
@ -352,10 +365,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
NULL);
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...
ShowWindow(hwnd, SW_SHOWNORMAL);