the Win32 seems to be fixed and working now
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
diff --git a/demos/graph/win32/grwin32.c b/demos/graph/win32/grwin32.c
index d489b8c..28bd363 100644
--- a/demos/graph/win32/grwin32.c
+++ b/demos/graph/win32/grwin32.c
@@ -96,6 +96,12 @@
{ VK_F12, grKeyF12 }
};
+ static
+ Translator syskey_translators[] =
+ {
+ { VK_F1, grKeyF1 }
+ };
+
/* This is a minimalist driver, it is only able to display */
/* a _single_ window. Moreover, only monochrome and gray */
/* bitmaps are supported.. */
@@ -209,18 +215,15 @@ void done_surface( grSurface* surface )
SetWindowText( hwndGraphic, the_title );
title_set = 1;
}
-
- do
+
+ eventToProcess = 0;
+ while (GetMessage( &msg, 0, 0, 0 ))
{
- while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) )
- {
- TranslateMessage( &msg );
- DispatchMessage( &msg );
- }
- if (!eventToProcess)
- WaitMessage();
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ if (eventToProcess)
+ break;
}
- while (!eventToProcess);
*grevent = ourevent;
}
@@ -400,7 +403,7 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
hwndGraphic = 0;
PostQuitMessage ( 0 );
DeleteObject ( hbm );
- break;
+ return 0;
case WM_CREATE:
{
@@ -432,17 +435,33 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
SelectObject ( memDC, oldbm );
DeleteObject ( memDC );
EndPaint ( handle, &ps );
- }
+ return 0;
+ }
- case WM_KEYDOWN:
case WM_SYSKEYDOWN:
+ {
+ int count = sizeof( syskey_translators )/sizeof( syskey_translators[0] );
+ Translator* trans = syskey_translators;
+ Translator* limit = trans + count;
+ for ( ; trans < limit; trans++ )
+ if ( wParam == trans->winkey )
+ {
+ ourevent.key = trans->grkey;
+ goto Do_Key_Event;
+ }
+ return DefWindowProc( handle, mess, wParam, lParam );
+ }
+
+
+ case WM_KEYDOWN:
switch ( wParam )
{
case VK_ESCAPE:
ourevent.type = gr_event_key;
ourevent.key = grKeyEsc;
eventToProcess = 1;
- break;
+ PostQuitMessage ( 0 );
+ return 0;
default:
/* lookup list of translated keys */
@@ -457,7 +476,11 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
goto Do_Key_Event;
}
}
- }
+
+ /* the key isn't found, default processing */
+ /* return DefWindowProc( handle, mess, wParam, lParam ); */
+ return DefWindowProc( handle, mess, wParam, lParam );
+ }
case WM_CHAR:
{
@@ -472,7 +495,6 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
default:
return DefWindowProc( handle, mess, wParam, lParam );
}
-
return 0;
}