ref: 587bc78f86e8e6809311b31ee985a85394976746
parent: 9c84887db3974b6ab9080cb8b0e492b3c6f866f0
author: David Turner <[email protected]>
date: Mon Feb 28 10:13:08 EST 2000
the Win32 seems to be fixed and working now
--- 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 @@
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 @@
hwndGraphic = 0;
PostQuitMessage ( 0 );
DeleteObject ( hbm );
- break;
+ return 0;
case WM_CREATE:
{
@@ -432,10 +435,25 @@
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:
@@ -442,7 +460,8 @@
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 @@
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 @@
default:
return DefWindowProc( handle, mess, wParam, lParam );
}
-
return 0;
}