/*-------------------------------------------------- * Replaces the accelerator keys used by the window *-------------------------------------------------*/ PMWindow& PMWindow::attach_accelerators( SHORT id ) { HACCEL h_accel = WinLoadAccelTable( PMGUI::hab(), 0, id ); if( h_accel == NULLHANDLE ) PM_THROW_GUIERROR(); if( !WinSetAccelTable( PMGUI::hab(), h_accel, handle())) PM_THROW_GUIERROR(); return *this; }
/*------------------------------------------------------------------------- CreatePopup --------------------------------------------------------------------------*/ void CreatePopup( HAB hab, HWND client, HWND frame ) { HACCEL haccel; if (Popup != NULLHANDLE) DestroyPopup(); Popup = WinLoadMenu( client, NULL, ID_POPUP ); haccel = WinLoadAccelTable( hab, NULLHANDLE, ID_ACCEL ); WinSetAccelTable( hab, haccel, frame ); return; }
/* Message processing for our PM Window class */ MRESULT EXPENTRY Message_Process( HWND handle, ULONG mess, MPARAM parm1, MPARAM parm2 ) { static HDC screen_dc; static HPS screen_ps; static BOOL minimized; SIZEL sizl; SWP swp; grPMSurface* surface; /* get the handle to the window's surface -- note that this */ /* value will be null when the window is created */ surface = (grPMSurface*)WinQueryWindowPtr( handle, QWL_USER ); if (!surface) { surface = the_surface; WinSetWindowPtr( handle, QWL_USER, surface ); } switch( mess ) { case WM_DESTROY: /* warn the main thread to quit if it didn't know */ surface->event.type = gr_event_key; surface->event.key = grKeyEsc; DosPostEventSem( surface->event_lock ); break; case WM_CREATE: /* set original magnification */ minimized = FALSE; /* create Device Context and Presentation Space for screen. */ screen_dc = WinOpenWindowDC( handle ); screen_ps = GpiCreatePS( surface->anchor, screen_dc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC | GPIF_DEFAULT ); /* take the input focus */ WinFocusChange( HWND_DESKTOP, handle, 0L ); LOG(( "screen_dc and screen_ps have been created\n" )); /* To permit F9, F10 and others to pass through to the application */ if (TRUE != WinSetAccelTable (surface->anchor, 0, surface->frame_window)) { printf( "Error - failed to clear accel table\n"); } break; case WM_MINMAXFRAME: /* to update minimized if changed */ swp = *((PSWP) parm1); if ( swp.fl & SWP_MINIMIZE ) minimized = TRUE; if ( swp.fl & SWP_RESTORE ) minimized = FALSE; return WinDefWindowProc( handle, mess, parm1, parm2 ); break; case WM_ERASEBACKGROUND: case WM_PAINT: /* copy the memory image of the screen out to the real screen */ LOCK( surface->image_lock ); WinBeginPaint( handle, screen_ps, NULL ); /* main image and magnified picture */ GpiBitBlt( screen_ps, surface->image_ps, 4L, surface->blit_points, ROP_SRCCOPY, BBO_AND ); WinEndPaint( screen_ps ); UNLOCK( surface->image_lock ); break; case WM_HELP: /* this really is a F1 Keypress !! */ surface->event.key = grKeyF1; goto Do_Key_Event; case WM_CHAR: if ( CHARMSG( &mess )->fs & KC_KEYUP ) break; /* look for a specific vkey */ { int count = sizeof( key_translators )/sizeof( key_translators[0] ); Translator* trans = key_translators; Translator* limit = trans + count; for ( ; trans < limit; trans++ ) if ( CHARMSG(&mess)->vkey == trans->os2key ) { surface->event.key = trans->grkey; goto Do_Key_Event; } } /* otherwise, simply record the character code */ if ( (CHARMSG( &mess )->fs & KC_CHAR) == 0 ) break; surface->event.key = CHARMSG(&mess)->chr; Do_Key_Event: surface->event.type = gr_event_key; DosPostEventSem( surface->event_lock ); break; default: return WinDefWindowProc( handle, mess, parm1, parm2 ); } return (MRESULT) FALSE; }