aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-12-09 23:31:14 +0100
committerSven Gothel <[email protected]>2010-12-09 23:31:14 +0100
commita92e315245f6cefb55a71572eab8b6c95e8041a3 (patch)
tree8de2a364fed04e928df41365e5e61cddb768ac9d /src/nativewindow
parentda97bc022020546455b293aea25dba3ee59152f5 (diff)
GDI: Fix CreateDummyWindow: Use local getModuleHandle(NULL) and synchronize factory method.
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/native/windows/GDImisc.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/src/nativewindow/native/windows/GDImisc.c b/src/nativewindow/native/windows/GDImisc.c
index 427e15d4a..0de40cf50 100644
--- a/src/nativewindow/native/windows/GDImisc.c
+++ b/src/nativewindow/native/windows/GDImisc.c
@@ -61,27 +61,48 @@ static jmethodID pointCstr = NULL;
#define NATIVEWINDOW_DUMMY_WINDOW_NAME "__nativewindow_dummy_window"
static ATOM nativewindowClass = 0;
+static HINSTANCE nativeHInstance = NULL;
LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
-HWND CreateDummyWindow0(HINSTANCE hInstance, int x, int y, int width, int height ) {
- DWORD dwExStyle;
- DWORD dwStyle;
- HWND hWnd;
+HWND CreateDummyWindow0(int x, int y, int width, int height ) {
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ HWND hWnd;
+ HINSTANCE hInstance = GetModuleHandle(NULL);
+ if( nativeHInstance != hInstance || 0 == nativewindowClass ) {
+ nativeHInstance=hInstance;
+ WNDCLASS wc;
+ ZeroMemory( &wc, sizeof( wc ) );
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ wc.lpfnWndProc = (WNDPROC) DummyWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = NULL;
+ wc.hCursor = NULL;
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = NATIVEWINDOW_DUMMY_WINDOW_NAME;
+ if( !(nativewindowClass = RegisterClass( &wc )) ) {
+ fprintf(stderr, "FatalError com_jogamp_nativewindow_impl_windows_GDI: RegisterClass Failed: %d\n", GetLastError() );
+ return( 0 );
+ }
+ }
- dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
- dwStyle = WS_OVERLAPPEDWINDOW;
- if( !(hWnd=CreateWindowEx( dwExStyle,
+ dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
+ dwStyle = WS_OVERLAPPEDWINDOW;
+ if( !(hWnd=CreateWindowEx( dwExStyle,
NATIVEWINDOW_DUMMY_WINDOW_NAME,
NATIVEWINDOW_DUMMY_WINDOW_NAME,
dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
x, y, width, height,
NULL, NULL, hInstance, NULL ) ) ) {
- return( 0 );
- }
- return( hWnd );
+ return( 0 );
+ }
+ return( hWnd );
}
/*
@@ -89,7 +110,7 @@ HWND CreateDummyWindow0(HINSTANCE hInstance, int x, int y, int width, int height
* Method: initIDs0
* Signature: ()Z
*/
-JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_windows_GDI_initIDs0
+JNIEXPORT jboolean JNICALL Java_com_jogamp_nativewindow_impl_windows_GDI_initIDs0
(JNIEnv *env, jclass clazz)
{
if(NULL==pointClz) {
@@ -108,25 +129,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_windows_GDI_initIDs0
ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature);
}
}
- HINSTANCE hInstance = GetModuleHandle(NULL);
- if( !nativewindowClass ) {
- WNDCLASS wc;
- ZeroMemory( &wc, sizeof( wc ) );
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- wc.lpfnWndProc = (WNDPROC) DummyWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = NULL;
- wc.hCursor = NULL;
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = NATIVEWINDOW_DUMMY_WINDOW_NAME;
- if( !(nativewindowClass = RegisterClass( &wc )) ) {
- _FatalError(env, "FatalError com_jogamp_nativewindow_impl_windows_GDI: RegisterClass Failed: %d", GetLastError() );
- }
- }
- return (jlong) hInstance;
+ return JNI_TRUE;
}
/*