/* -*-C-*-
-$Id: ntscreen.c,v 1.13 1993/09/01 18:48:27 gjr Exp $
+$Id: ntscreen.c,v 1.14 1993/09/03 18:01:28 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
#include <stdlib.h>
#include "ntscreen.h"
//#include "screen.rh"
+/* Allow conditionalization for underlying OS. */
+extern BOOL win32_under_win32s_p (void);
\f
// constant definitions
BOOL
init_color (char * color_symbol, HWND hWnd, DWORD * color)
{
+ HDC hdc;
char * envvar = (getenv (color_symbol));
if (envvar == NULL)
return (FALSE);
/* Use GetNearestColor to ensure consistency with the background
text color.
*/
- * color = (GetNearestColor ((GetDC (hWnd)), (strtoul (envvar, NULL, 0))));
+ hdc = (GetDC (hWnd));
+ * color = (GetNearestColor (hdc, (strtoul (envvar, NULL, 0))));
+ ReleaseDC (hWnd, hdc);
return (TRUE);
}
params[2], params[3],
hParent, NULL, ghInstance,
((LPVOID) nCmdShow)));
-#if 0
- if ((hParent == ((HWND) NULL)) && (hwnd != NULL))
- if (! (RegisterHotKey (hwnd, 0x0001, MOD_CONTROL, VK_F10)))
- MessageBox (NULL, "No hot key", "MIT Scheme", MB_OK);
-#endif
-
return (hwnd);
}
void
Screen_Destroy (BOOL root, HANDLE hwnd)
{
-#if 0
- if (root)
- UnregisterHotKey (hwnd, 0x0001);
-#endif
DestroyWindow (hwnd);
return;
}
goto use_default;
}
-#if 0
+#ifdef USE_WM_TIMER
case WM_TIMER:
{
extern VOID TimerProc (HWND, UINT, UINT, DWORD);
TimerProc (hWnd, uMsg, wParam, lParam);
return (0L);
}
-#endif
+#endif /* USE_WM_TIMER */
case WM_HOTKEY:
{
min(maxsz.x,max(minsz.x,width)),
min(maxsz.y,max(minsz.y,height)), TRUE);
else
- SendMessage (hWnd, WM_SIZE, SIZENORMAL,
+ PostMessage (hWnd, WM_SIZE, SIZENORMAL,
((LPARAM) (MAKELONG (width,height))));
}
//
//---------------------------------------------------------------------------
-extern BOOL win32_under_win32s_p (void);
-
static BOOL
SizeScreen (HWND hWnd, WORD wVertSize, WORD wHorzSize )
{
}
}
- InvalidateRect (hWnd, NULL, TRUE);
+ {
+ /* The SendMessage stuff works fine under NT, but wedges Win 3.1.
+ The only solution I've found is to redraw the whole screen.
+ */
+
+ if (win32_under_win32s_p ())
+ InvalidateRect (NULL, NULL, TRUE);
+ else
+ {
+ HDC hdc = (GetDC (hWnd));
+ InvalidateRect (hWnd, NULL, TRUE);
+ SendMessage (hWnd, WM_ERASEBKGND, ((WPARAM) hdc), ((LPARAM) 0));
+ ReleaseDC (hWnd, hdc);
+ }
+ }
return TRUE;
} // end of SizeScreen
cfTTYFont.hDC = NULL ;
cfTTYFont.rgbColors = screen->rgbFGColour;
cfTTYFont.lpLogFont = &screen->lfFont;
- cfTTYFont.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY |
- CF_EFFECTS | CF_INITTOLOGFONTSTRUCT ;
+ cfTTYFont.Flags = (
+ CF_FIXEDPITCHONLY
+ | CF_SCREENFONTS
+ | CF_EFFECTS
+ | CF_INITTOLOGFONTSTRUCT
+ );
cfTTYFont.lCustData = 0 ;
cfTTYFont.lpfnHook = NULL ;
cfTTYFont.lpTemplateName = NULL ;
screen->bkgnd_brush = (CreateSolidBrush (screen->rgbBGColour));
InvalidateRect (owner, NULL, TRUE);
SendMessage (owner, WM_ERASEBKGND, ((WPARAM) hdc), ((LPARAM) 0));
+ ReleaseDC (owner, hdc);
}
return (TRUE);
}
return &link->event;
}
+\f
+BOOL
+Screen_GetEvent (HANDLE hwnd, SCREEN_EVENT *event)
+{
+ SCREEN_EVENT_LINK *link;
+ SCREEN screen = (GETSCREEN (hwnd));
+
+ if ((screen == ((SCREEN) NULL))
+ || (screen->n_events == 0))
+ return (FALSE);
+ screen->n_events -= 1;
+ link = screen->queue_head;
+ (*event) = link->event;
+ screen->queue_head = link->next;
+ link->next = screen->free_events;
+ screen->free_events = link;
+ return TRUE;
+}
BOOL
-Screen_GetEvent (SCREEN screen, SCREEN_EVENT *event)
+Screen_PeekEvent (HANDLE hwnd, SCREEN_EVENT * event)
{
- SCREEN_EVENT_LINK *link;
- if (screen->n_events == 0)
- return FALSE;
- screen->n_events -= 1;
- link = screen->queue_head;
- (*event) = link->event;
- screen->queue_head = link->next;
- link->next = screen->free_events;
- screen->free_events = link;
- return TRUE;
+ SCREEN screen = (GETSCREEN (hwnd));
+
+ if ((screen == ((SCREEN) NULL))
+ || (screen->n_events == 0))
+ return (FALSE);
+ if (event != ((SCREEN_EVENT *) NULL))
+ (* event) = screen->queue_head->event;
+ return (TRUE);
}
\f
//---------------------------------------------------------------------------