MRESULT mainhewmInit(HWND hwnd,MPARAM mp1,MPARAM mp2) { HWND hwndFrame = WinQueryWindow(hwnd,QW_PARENT); // printf("HEWM_INIT\n"); if (bootopen) han_type = HEFileOpenWithAutoHanCode(hwnd,bootopen,TRUE); HESetTitlebarText(hwnd); WinPostMsg(hwndHIA,HIAM_SETKBDTYPE,MPFROMLONG(kbd_type),0L); WinPostMsg(hwndHMLE,HMLM_SETTEXTFORMAT,MPFROMLONG(eol_type),0L); WinPostMsg(hwndStatbar,STATBAR_USERM_SETEOLTYPE,MPFROMLONG(eol_type),0L); WinPostMsg(hwndStatbar,STATBAR_USERM_SETHANTYPE,MPFROMLONG(han_type),0L); if (readonly) { WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_IMPORT,FALSE ); WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_SAVE,FALSE); //WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_SAVEAS,FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_SAVE),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_CUT),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_PASTE),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_SHOWITEM,MPFROMLONG(TOOLBAR_CLEAR),FALSE); WinPostMsg(hwndToolbar,TOOLBAR_USERM_UPDATE,0,0); } WinEnableMenuItem(WinWindowFromID(hwndFrame,FID_MENU),IDM_PROPERTIES,FALSE); WinSetFocus(HWND_DESKTOP,hwndHMLE); return 0L; }
// ******************************************************************************* // FUNCTION: ToggleEditMenu // // FUNCTION USE: Will enable or disable menuitems from the edit menu accordingly // // DESCRIPTION: This function will enable or disable the cut, copy and paste // menuitems. // // PARAMETERS: HWND The handle of the menu window // USHORT The identifier of the menuitem to enable or disable // HBITMAP The bitmap handle // // RETURNS: VOID // // HISTORY: // // ******************************************************************************* VOID ToggleEditMenu(HWND hwndMenu, USHORT usID, HBITMAP hbmClip) { BOOL rc; ULONG ulFormat; HAB hab; // -------------------------------------------------------------------------- // Get an anchor block handle // -------------------------------------------------------------------------- hab = WinQueryAnchorBlock(WinQueryWindow(hwndMenu, QW_PARENT)); switch (usID) { case IDM_EDITCUT: case IDM_EDITCOPY: case IDM_EDITCLEAR: // -------------------------------------------------------------------------- // Enable cut and copy if we have a valid bitmap handle from our // tracking operation. // -------------------------------------------------------------------------- if (hbmClip) { WinEnableMenuItem(hwndMenu, usID, TRUE); } // -------------------------------------------------------------------------- // Disable cut and copy if we don't have a bitmap // -------------------------------------------------------------------------- else { WinEnableMenuItem(hwndMenu, usID, FALSE); } return; case IDM_EDITPASTE: // -------------------------------------------------------------------------- // Enable paste if we have a valid bitmap handle in the clipboard. // -------------------------------------------------------------------------- rc = WinQueryClipbrdFmtInfo (hab, CF_BITMAP, &ulFormat); if (rc) { WinEnableMenuItem(hwndMenu, usID, TRUE); } // -------------------------------------------------------------------------- // Disable paste if we do not have a valid bitmap. // -------------------------------------------------------------------------- else { WinEnableMenuItem(hwndMenu, usID, FALSE); } return; } }
MRESULT mainwmButton2Up( HWND hwnd, MPARAM mp1, MPARAM mp2 ) { POINTS pts; ULONG fs = PU_POSITIONONITEM | PU_NONE | PU_SELECTITEM | PU_KEYBOARD | PU_MOUSEBUTTON1; WinEnableMenuItem( hwndPopupMenu, IDM_COPY, markingState ); WinEnableMenuItem( hwndPopupMenu, IDM_CUT, markingState ); WinEnableMenuItem( hwndPopupMenu, IDM_CLEAR, markingState ); pts.x = SHORT1FROMMP( mp1 ); pts.y = SHORT2FROMMP( mp1 ); WinPopupMenu( hwnd, hwnd, hwndPopupMenu, pts.x, pts.y, IDM_PASTE, fs ); return 0L; }
/************************************************************************** * * FUNCTION NAME: ProcessRegisterDialog * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ MRESULT EXPENTRY ProcessRegisterDialog (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { CHAR szID[50]; switch (msg) { case WM_INITDLG : /* Center the dialog box in the frame window of the parent */ CenterDialog (hwnd); return (0); case WM_COMMAND : switch (SHORT1FROMMP (mp1)) { case DID_OK: WinQueryDlgItemText (hwnd, REG_NAME_ID, REGISTER_NAME_LEN, gszRegName); WinQueryDlgItemText (hwnd, REG_ID_ID, sizeof(szID), szID); if (CheckPassword (gszRegName, szID)) { /* The password is cool! Save the settings now */ WinDlgBox (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, CONGRATS_DLG_ID, NULL); gfRegistered = TRUE; WriteIniFile (); /* Disable the register menu item now we're registered */ WinEnableMenuItem (hwndMenu, MENU_REGISTER_ID, !gfRegistered); WinDismissDlg (hwnd, DID_OK); } else { WinDlgBox (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, SORRY_DLG_ID, NULL); } return (0); case DID_CANCEL: /* Dismiss the dialog without saving the values */ WinDismissDlg (hwnd, DID_CANCEL); return (0); case DID_HELP: /* Display the keys help panel */ WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, MPFROM2SHORT(PANEL_REGISTER, NULL), MPFROMSHORT(HM_RESOURCEID)); return (0); default: break; } break; default: break; } return (WinDefDlgProc (hwnd, msg, mp1, mp2)); }
/************************************************************************* * * Name : WinProc(hwnd, msg, mp1, mp2) * * Description: Processes the messages sent to the main client * window. This routine processes the basic * messages all client windows should process. * * Concepts : This procedure provides service routines for the general * PM events (messages) that PM sends to the window, as well * as the user initiated events (messages) that are generated * when the user selects the action bar and pulldown menu * controls or the corresponding keyboard accelerators. * * The switch statement shown below distributes the window * messages to the respective message service routines, which * are set apart by the case statements. The window * procedures must provide an appropriate service routine for * its end user initiated messages, as well as the general PM * messages (like the WM_CLOSE message). If a message is sent * to this procedure for which there is no programmed case * clause (i.e., no service routine), the message is defaulted * function WinDefWindowProc, where it is disposed of by PM. * * Time-consuming tasks are posted to the object window where * they can be performed without the 1/10 second turnaround * time imposed on the client window. When the object window * is busy, the client window is usually disabled. The object * window then posts an acknowledgement * back to the client when the lengthy task is completed. * * Cases under the big switch appear in alphabetical order. * * API's : WinLoadString * WinMessageBox * WinQueryWindowULong * WinSendMsg * WinPostMsg * WinIsWindowEnabled * WinSetPointer * WinQuerySysPointer * WinBeginPaint * WinQueryWindowRect * WinFillRect * WinEndPaint * WinInvalidateRect * WinSetWindowText * GpiDrawChain * GpiConvert * GpiSetDefaultViewMatrix * GpiAssociate * GpiDestroyPS * GpiDeleteBitmap * GpiDeleteMetafile * * Parameters : HWND window handle * ULONG message * MPARAM message parameter 1 * MPARAM message parameter 2 * * Result : MRESULT message result * *************************************************************************/ MRESULT EXPENTRY WinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { BOOL bOK; PMAIN_PARM pmp; HPS hps; RECTL rectl; PSZ psz; CHAR szWork[ LEN_WORKSTRING ]; SHORT sStep; ULONG ulWork; SHORT sNewPos; ULONG rc; switch(msg) { case WM_CLOSE: /* obtain the main parameter pointer from window words */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); #ifdef OSA_AWARE /* Do OSA termination */ TerminateOSA(hwnd); #endif if( pmp->fBusy ) { /* OK to close when object window is busy? */ WinLoadString( pmp->hab, (HMODULE)NULLHANDLE, ERRMSG_CLOSE_QUESTION, LEN_WORKSTRING, szWork ); ulWork = WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_YESNOCANCEL | MB_MOVEABLE | MB_CUANOTIFICATION | MB_APPLMODAL); if( ulWork == MBID_YES ) { /* close down the application in spite of being busy */ pmp->fCancel = TRUE; /* disable client during exit */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0 , (MPARAM)0 ); /* start a watchdog timer to ensure a timely death */ WinStartTimer( pmp->hab, hwnd, ID_DEATH_TIMER, LEN_DEATH_TIMER ); /* Tell object window to close, quit, and post me a WM_QUIT */ WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 ); } } else { /* not busy, so initiate closure by telling object window to close */ WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 ); } return (MRESULT)NULL; case WM_COMMAND: /* do menu activities; see menu.c */ return Menu( hwnd, msg, mp1, mp2 ); case WM_CREATE: /* * Do one-time, startup processing in PRTCREAT.C. * This function allocates the pmp, a pointer to the program's * main parameters. See the declaration of this block of * parameters in PRTSAMP.H, the MAIN_PARM structure. * * The Create() function allocates this structure and * begins to initialize it. Throughout all the code, the pmp-> * pointer is usually obtainable with a call to WinQueryWindowULong. * Window word space for this pointer was reserved on the call * to WinRegisterClass. * * Create() allocates, initializes, and stores the pmp pointer * in the client window words. It then starts thread 2 of the * application on which the object window operates. The pmp * pointer is passed to thread 2 with _beginthread in PRTCREAT.C. * The pmp is passed to the object window on the call to * WinCreateWindow in PRTOBJ.C. Finally, the object window stores * the pmp in its window words under the WM_CREATE case of the * ObjectWinProc in PRTOBJ.C. * */ Create( hwnd ); #ifdef OSA_AWARE /* Do OSA Initialization */ InitOSA(hwnd); #endif #ifdef OSA_AWARE /* Generate a Apple Event - Open Application to myself (Workaround) */ rc = GenerateOSAEvent(hwnd, msg, MPFROMSHORT(IDM_AEOPENAPP), mp2); #endif return (MRESULT)NULL; case WM_HSCROLL: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* Compute some fraction of scroll bar range for a unit of scrolling. */ sStep = pmp->sHScrollRange / 50; switch( SHORT2FROMMP( mp2 )) { case SB_LINELEFT: pmp->sHScrollPos -= sStep; break; case SB_PAGELEFT: pmp->sHScrollPos -= pmp->sizelClient.cx; break; case SB_LINERIGHT: pmp->sHScrollPos += sStep; break; case SB_PAGERIGHT: pmp->sHScrollPos += pmp->sizelClient.cx; break; case SB_SLIDERPOSITION: case SB_SLIDERTRACK: pmp->sHScrollPos = SHORT1FROMMP( mp2 ); break; } /* Don't allow step assignments to exceed limits of zero to range. */ pmp->sHScrollPos = max( (SHORT)0, min( pmp->sHScrollPos, pmp->sHScrollRange )); if( pmp->sHScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndHScroll, SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 ))) { /* * New scroll bar thumbbutton position is different than current. * Set a new X translation value to effect the scroll. * Current scale setting affects the X element of the matrix. */ pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale * (float)( pmp->sHScrollPos)); bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); CalibrateHorizontalScrollBar( pmp ); WinInvalidateRect( hwnd, NULL, FALSE ); } return (MRESULT) 0; case WM_MOUSEMOVE: /* display which pointer? -- could query pmp->fBusy or... */ if( WinIsWindowEnabled( hwnd )) { /* not disabled; display regular pointer */ WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE )); } else { /* disabled; display hourglass because I'm busy */ WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE )); } return (MRESULT) 1; case WM_NACK_BITMAP_NOT_SUPPORTED: /* * Object window does not support this format of bitmap - * show a message box. */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); bOK = WinLoadString( pmp->hab, (HMODULE)0, ERRMSG_BITMAP_NOT_SUPPORTED, LEN_WORKSTRING, szWork ); pmassert( pmp->hab, bOK ); WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL); pmp->ulNextMode = MODE_UNKNOWN; pmp->szNextFilename[0] = 0; WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 ); return (MRESULT) 0; case WM_NACK_BITMAP_ERROR: /* * Object window had error loading the bitmap file - * show a message box */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); bOK = WinLoadString( pmp->hab, (HMODULE)NULLHANDLE, ERRMSG_BAD_BITMAP, LEN_WORKSTRING, szWork ); pmassert( pmp->hab, bOK ); WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL); pmp->ulNextMode = MODE_UNKNOWN; pmp->szNextFilename[0] = 0; WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 ); return (MRESULT) 0; case WM_NACK_FILE_READING_ERROR: /* * Object window had a problem with reading the disk - * show a message box. */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); bOK = WinLoadString( pmp->hab, (HMODULE)NULLHANDLE, ERRMSG_READ_ERROR, LEN_WORKSTRING, szWork ); pmassert( pmp->hab, bOK ); WinMessageBox( HWND_DESKTOP, pmp->hwndFrame, szWork, pmp->pszTitle, (USHORT)0, MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL); pmp->ulNextMode = MODE_UNKNOWN; pmp->szNextFilename[0] = 0; WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 ); return (MRESULT) 0; case WM_PAINT: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* do not rely on client window rectangle being correct */ WinQueryUpdateRect( hwnd, &rectl ); WinQueryWindowRect( hwnd, &rectl ); /* current mode of the program affects window painting */ switch( pmp->ulMode ) { case MODE_UNKNOWN: WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); WinPostMsg( pmp->hwndObject, WM_USER_PAINT_DEFAULT_SCREEN, (MPARAM)hwnd, (MPARAM)0 ); /* must call default window proc for window validation */ break; case MODE_TEXT: if( pmp->fBusy ) { /* * Object window is busy with the client PS drawing into * retained segments. Use a cached micro PS to merely * fill the client window with a background wash. * * Proper painting of the text will occur in due time * because the WM_USER_ACK case below will * invalidate the client window and force a paint. * The object window won't be busy then. */ hps = WinBeginPaint( hwnd, (HPS) 0, &rectl ); pmassert( pmp->hab, hps ); bOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW ); pmassert( pmp->hab, bOK ); WinEndPaint( hps ); } else { /* PS not busy. Use GpiDrawChain to repaint the text */ hps = WinBeginPaint( hwnd, (HPS)pmp->hpsClient, &rectl ); pmassert( pmp->hab, hps ); bOK = WinFillRect( pmp->hpsClient, &rectl, SYSCLR_WINDOW ); pmassert( pmp->hab, bOK ); /* * GpiDrawChain re-plays the GpiCharString orders that were * retain in the WM_USER_PAGINATE case in prtobj.c */ bOK = GpiDrawChain( pmp->hpsClient ); pmassert( pmp->hab, bOK ); bOK = WinEndPaint( pmp->hpsClient ); pmassert( pmp->hab, bOK ); } return (MRESULT) 0; case MODE_BITMAP: if( pmp->hbm ) { WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); WinPostMsg( pmp->hwndObject, WM_USER_PAINT_BITMAP, (MPARAM)hwnd, (MPARAM)0 ); } /* must call default window proc for window validation */ break; case MODE_METAFILE: hps = WinBeginPaint( hwnd, (HPS) 0, &rectl ); pmassert( pmp->hab, hps ); WinFillRect( hps, &rectl, SYSCLR_WINDOW ); if( pmp->hmf ) { WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); WinPostMsg( pmp->hwndObject, WM_USER_PAINT_METAFILE, (MPARAM)hwnd, (MPARAM)0 ); } WinEndPaint( hps ); return (MRESULT) 0; default: pmassert( pmp->hab, NULL == "bad case in WM_PAINT" ); } break; #ifdef OSA_AWARE case WM_SEMANTICEVENT: /* Handle Apple Event Manager Semantic Event */ WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "WM_SEMANTIC_EVENT was received", "WinProc", (USHORT)0, MB_OK | MB_NOICON); /* Call ProcessSemanticEvent to process the Apple Event */ ProcessSemanticEvent( hwnd, msg, mp1, mp2 ); return (MRESULT) 0; #endif case WM_SIZE: /* Do size process if frame is not minimized */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* * If the object window is busy drawing, the GPI calls here can fail * because the PS is busy. Check for this situation and delay * the sizing operation by a few milliseconds. */ if( pmp->fBusy ) { WinStartTimer( pmp->hab, hwnd, ID_SIZE_TIMER, LEN_SIZE_TIMER ); return (MRESULT) 0; } ulWork = WinQueryWindowULong( pmp->hwndFrame, QWL_STYLE ); if( !( ulWork & WS_MINIMIZED )) { /* Frame is not minimized. Get window size in pels. */ WinQueryWindowRect( hwnd, &rectl ); /* how many twips will fit into the client window now? */ bOK = GpiConvert( pmp->hpsClient, CVTC_DEVICE, CVTC_WORLD, 2L, (PPOINTL)&rectl ); pmassert( pmp->hab, bOK ); /* compute client size in twips, store in pmp */ pmp->sizelClient.cx = rectl.xRight - rectl.xLeft; pmp->sizelClient.cy = rectl.yTop - rectl.yBottom; /* Try to keep the current position still in view by calculating */ /* the difference between size required and client window. */ /* The scroll position is then either 0 or the minimum of the */ /* difference and the old scroll position */ sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxxWidth) + (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) - pmp->sizelClient.cx; pmp->sHScrollPos = min( max( 0, sNewPos), pmp->sHScrollPos); sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxyHeight) + (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) - pmp->sizelClient.cy; pmp->sVScrollPos = min( max( 0, sNewPos), pmp->sVScrollPos); /* recalibrate the scroll bars */ CalibrateHorizontalScrollBar( pmp ); CalibrateVerticalScrollBar( pmp ); /* * Modify def-view matrix translation to home the displayed page. * This depends on the current scaling value. */ pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale * (float)( pmp->sHScrollPos)); pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale * (float)( pmp->sVScrollPos - pmp->sVScrollRange )); bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); /* force a paint */ WinInvalidateRect( hwnd, NULL, FALSE ); } return (MRESULT) 0; case WM_TIMER: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); switch( (ULONG) mp1 ) { case ID_DEATH_TIMER: /* object window never posted a quit in allotted time. WinPostMsg( hwnd, WM_QUIT, 0, 0 ); break; case ID_SIZE_TIMER: /* object window was busy with the PS before; try sizing now */ bOK = WinStopTimer( pmp->hab, hwnd, ID_SIZE_TIMER ); pmassert( pmp->hab, bOK ); WinSendMsg( hwnd, WM_SIZE, 0, 0 ); break; } return (MRESULT) 0; case WM_USER_ACK: /* * Object window is done processing lengthy task. * mp1 contains the WM_USER msg originally posted to the object window * mp2 may contain a result code, depending on mp1 */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* reenable the client window */ WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 ); switch( (ULONG)mp1 ) { case WM_USER_LOAD_BITMAP: case WM_USER_LOAD_METAFILE: case WM_USER_LOAD_TEXT: /* * Do size processing so that document will * "home" in the client window. */ WinSendMsg( hwnd, WM_SIZE, (MPARAM)0, (MPARAM)0 ); break; case WM_USER_PAGINATE: switch( (ULONG)mp2 ) { case PAGINATE_EOF: case PAGINATE_EOF_PART_PAGE: /* seek top of file */ fseek( pmp->f, 0, SEEK_SET ); } WinInvalidateRect( hwnd, NULL, FALSE ); break; } return (MRESULT) 0; case WM_USER_DISABLE_CLIENT: /* * usually disable before posting a task to the object window * this message may be sent; disable menu action bar as well */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); pmp->fBusy = TRUE; WinEnableWindow( pmp->hwndClient, FALSE ); WinEnableWindow( pmp->hwndMenubar, FALSE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, FALSE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE ); return (MRESULT)0; case WM_USER_ENABLE_CLIENT: /* * usually enable upon receipt of object window ack/nack * this message may be sent; enable menu actions if text mode */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); pmp->fBusy = FALSE; WinEnableWindow( pmp->hwndClient, TRUE ); WinEnableWindow( pmp->hwndMenubar, TRUE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, TRUE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE ); if( pmp->ulMode == MODE_TEXT ) { WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE ); } return (MRESULT) 0; case WM_USER_NEW_MODE: /* * The program now has a new file, file type, or printer, or * printer form, orientation, resolution, etc. The receipt * and processing of this message works to reset the program: * Old file, bitmap, or metafile handles are closed, and * new ones get opened. The titlebar shows the new filename. * This case works very much like a program reset. */ pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* close processing on current file */ switch( pmp->ulMode ) { case MODE_BITMAP: /* destroy previous memory dc, ps, and hbm */ if( pmp->hpsMemory ) { GpiAssociate( pmp->hpsMemory, (HDC)0 ); GpiDestroyPS( pmp->hpsMemory ); pmp->hpsMemory = (HPS) 0; } if( pmp->hdcMemory ) { DevCloseDC( pmp->hdcMemory ); pmp->hdcMemory = (HDC) 0; } if( pmp->hbm ) { GpiDeleteBitmap( pmp->hbm ); pmp->hbm = (HBITMAP) 0; } break; case MODE_METAFILE: /* destroy old metafile handle */ if( pmp->hmf ) { GpiDeleteMetaFile( pmp->hmf ); pmp->hmf = (HMF) 0; } break; case MODE_TEXT: fclose( pmp->f ); pmp->f = (FILE *) 0; /* turn off options for text mode */ WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT, FALSE ); break; } /* turn off options for all modes */ WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, FALSE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, FALSE ); /* copy over current values with the next values */ pmp->ulMode = pmp->ulNextMode; strcpy( pmp->szFilename, pmp->szNextFilename ); /* enable the print menu option if mode is known and there is a printer set up. */ WinEnableMenuItem( pmp->hwndMenubar, IDM_PRINT, (pmp->ulMode != MODE_UNKNOWN && pmp->hpsPrinterInfo ) ); /* update title bar text and show filename in use */ if( *pmp->szFilename ) { /* parse full-qualified filename to just get filename and extension */ psz = strrchr( pmp->szFilename, '\\' ); if (psz && *psz) { ++psz; } else { psz = pmp->szFilename; } sprintf( szWork, "%s - %s", pmp->pszTitle, psz ); } else { strcpy( szWork, pmp->pszTitle ); } WinSetWindowText( pmp->hwndTitlebar, szWork ); /* enable options for all modes */ WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE ); WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL, TRUE ); WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL, TRUE ); /* process this new mode */ switch( pmp->ulMode ) { case MODE_BITMAP: /* load the bitmap into memory so it is compatible with the screen */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); WinPostMsg( pmp->hwndObject, WM_USER_LOAD_BITMAP, (MPARAM)hwnd, (MPARAM)FLAGS_SCREEN ); break; case MODE_METAFILE: /* make object window read metafile */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); WinPostMsg( pmp->hwndObject, WM_USER_LOAD_METAFILE, (MPARAM)hwnd, 0 ); break; case MODE_TEXT: /* turn on options for text mode */ WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE ); WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT, TRUE ); /* reset view matrix that was last in effect for viewing text pages; */ /* this gets lost after viewing a metafile */ bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); /* disable until text loaded */ WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); /* tell object window to load the text file */ bOK = WinPostMsg( pmp->hwndObject, WM_USER_LOAD_TEXT, (MPARAM)hwnd, 0 ); pmassert( pmp->hab, bOK ); break; case MODE_UNKNOWN: /* size screen to get correct scrollbars */ WinPostMsg( pmp->hwndClient, WM_SIZE, 0, 0 ); break; } return (MRESULT) 0; case WM_VSCROLL: pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER ); /* Compute some fraction of scroll bar range for a unit of scrolling. */ sStep = pmp->sVScrollRange / 50; switch( SHORT2FROMMP( mp2 )) { case SB_LINEUP: pmp->sVScrollPos -= sStep; break; case SB_PAGEUP: pmp->sVScrollPos -= pmp->sizelClient.cy; break; case SB_LINEDOWN: pmp->sVScrollPos += sStep; break; case SB_PAGEDOWN: pmp->sVScrollPos += pmp->sizelClient.cy; break; case SB_SLIDERPOSITION: case SB_SLIDERTRACK: sNewPos = SHORT1FROMMP( mp2 ); pmp->sVScrollPos = sNewPos; break; } /* Don't allow step assignments to exceed limits of zero to range. */ pmp->sVScrollPos = max( (SHORT)0, min( pmp->sVScrollPos, pmp->sVScrollRange )); if( pmp->sVScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndVScroll, SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 ))) { /* * New scroll bar thumbbutton position is different than current. * Set a new Y translation value to effect the scroll. * Current scale setting affects the Y element of the matrix. */ pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale * (float)( pmp->sVScrollPos - pmp->sVScrollRange )); pmp->matlfDefView.lM32 = (LONG)(pmp->floatScale * (float)( OFFSET_XY_TWIPS + pmp->sVScrollPos - pmp->sVScrollRange )); bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9, &pmp->matlfDefView, TRANSFORM_REPLACE ); pmassert( pmp->hab, bOK ); CalibrateVerticalScrollBar( pmp ); WinInvalidateRect( hwnd, NULL, FALSE ); } return (MRESULT) 0; } return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } /* End of WinProc */
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static BOOL fContinueCalc = FALSE ; static HAB hab ; static HWND hwndMenu ; static INT iStatus = STATUS_READY ; static INT iCurrentRep = IDM_10 ; static LONG lCalcRep, lRepAmts [] = { 10, 100, 1000, 10000, 100000 } ; static ULONG ulElapsedTime ; double A ; LONG lRep ; QMSG qmsg ; switch (msg) { case WM_CREATE: hab = WinQueryAnchorBlock (hwnd) ; hwndMenu = WinWindowFromID ( WinQueryWindow (hwnd, QW_PARENT), FID_MENU) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_10: case IDM_100: case IDM_1000: case IDM_10000: case IDM_100000: WinCheckMenuItem (hwndMenu, iCurrentRep, FALSE) ; iCurrentRep = COMMANDMSG(&msg)->cmd ; WinCheckMenuItem (hwndMenu, iCurrentRep, TRUE) ; return 0 ; case IDM_START: WinEnableMenuItem (hwndMenu, IDM_START, FALSE) ; WinEnableMenuItem (hwndMenu, IDM_ABORT, TRUE) ; iStatus = STATUS_WORKING ; WinInvalidateRect (hwnd, NULL, FALSE) ; lCalcRep = lRepAmts [iCurrentRep - IDM_10] ; fContinueCalc = TRUE ; ulElapsedTime = WinGetCurrentTime (hab) ; qmsg.msg = WM_NULL ; for (A = 1.0, lRep = 0 ; lRep < lCalcRep ; lRep++) { A = Savage (A) ; while (WinPeekMsg (hab, &qmsg, NULLHANDLE, 0, 0, PM_NOREMOVE)) { if (qmsg.msg == WM_QUIT) break ; WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0) ; WinDispatchMsg (hab, &qmsg) ; if (!fContinueCalc) break ; } if (!fContinueCalc || qmsg.msg == WM_QUIT) break ; } ulElapsedTime = WinGetCurrentTime (hab) - ulElapsedTime ; if (!fContinueCalc || qmsg.msg == WM_QUIT) iStatus = STATUS_READY ; else iStatus = STATUS_DONE ; WinInvalidateRect (hwnd, NULL, FALSE) ; WinEnableMenuItem (hwndMenu, IDM_START, TRUE) ; WinEnableMenuItem (hwndMenu, IDM_ABORT, FALSE) ; return 0 ; case IDM_ABORT: fContinueCalc = FALSE ; return 0 ; } break ; case WM_PAINT: PaintWindow (hwnd, iStatus, lCalcRep, ulElapsedTime) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
// ------------------------------------------------------------------------------------------------------------ MRESULT EXPENTRY ClientWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { BOOL fOK; RECTL rectl; SIZEL sizel; HPS hps; switch( msg ) { case WM_CLOSE: globals.fCloseMsgSent = TRUE; WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); WinPostMsg( globals.hwndObject, WM_QUIT, 0, 0 ); return 0; case WM_COMMAND: switch( SHORT1FROMMP( mp1 )) { case ID_RUN: WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); WinInvalidateRect( hwnd, NULL, FALSE ); WinPostMsg( globals.hwndObject, WM_USER_START_REXX, (MPARAM)hwnd, 0 ); break; } return 0; case WM_CREATE: // disable client window until application initializes WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); globals.hwndFrame = WinQueryWindow( hwnd, QW_PARENT ); globals.hwndTitlebar = WinWindowFromID( globals.hwndFrame, FID_TITLEBAR ); globals.hwndMenubar = WinWindowFromID( globals.hwndFrame, FID_MENU ); // create title bar text; set into title bar sprintf( globals.szCaption, "%s - %s", CAPTION, globals.szRexxFileName ); WinSetWindowText( globals.hwndTitlebar, globals.szCaption ); // get window DC globals.hdcScreen = WinOpenWindowDC( hwnd ); assert( globals.hdcScreen ); // create a normal PS for the screen; coordinate system is 1/100 inch per unit of measure sizel.cx = sizel.cy = 0; globals.hpsScreen = GpiCreatePS( globals.hab, globals.hdcScreen, &sizel, PU_LOENGLISH | GPIF_LONG | GPIT_NORMAL | GPIA_ASSOC ); assert( globals.hpsScreen ); // object window operates on thread 2 globals.tidObject = _beginthread( threadmain, NULL, LEN_STACK, NULL ); assert( globals.tidObject ); return 0; case WM_MOUSEMOVE: WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, globals.fBusy ? SPTR_WAIT:SPTR_ARROW, FALSE )); return (MRESULT)1; case WM_PAINT: hps = WinBeginPaint( hwnd, globals.hpsScreen, &rectl ); fOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW ); assert( fOK ); if( !globals.fBusy ) { // playback the retained GPI drawing orders GpiDrawChain( globals.hpsScreen ); } WinEndPaint( hps ); return 0; case WM_USER_ACK: // object window has posted ack; re-enable the window WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 ); return 0; case WM_USER_DISABLE_CLIENT: globals.fBusy = TRUE; WinEnableWindow( globals.hwndClient, FALSE ); WinEnableMenuItem( globals.hwndMenubar, ID_RUN, FALSE ); return 0; case WM_USER_ENABLE_CLIENT: globals.fBusy = FALSE; WinEnableWindow( globals.hwndClient, TRUE ); WinEnableMenuItem( globals.hwndMenubar, ID_RUN, TRUE ); return 0; } return WinDefWindowProc( hwnd, msg, mp1, mp2 ); }
MRESULT os2FrameWindow::ProcessFrameMessage(ULONG msg, MPARAM mp1, MPARAM mp2) { MRESULT mresult = 0; bool isDone = false; switch (msg) { case WM_WINDOWPOSCHANGED: { PSWP pSwp = (PSWP)mp1; // Don't save the new position or size of a minimized // window, or else it won't be restored correctly. if (pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE)) { POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy }; ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y; mFrameBounds.x = ptl.x; mFrameBounds.y = ptl.y; mOwner->DispatchMoveEvent(ptl.x, ptl.y); } // Save the frame's bounds, then call the default wndproc // so the client can handle its WM_WINDOWPOSCHANGED msg now. if (pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE)) { mFrameBounds.width = pSwp->cx; mFrameBounds.height = pSwp->cy; mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2); isDone = true; } if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) { if (mOwner->mWidgetListener) { nsSizeMode mode; if (pSwp->fl & SWP_MAXIMIZE) { mode = nsSizeMode_Maximized; } else if (pSwp->fl & SWP_MINIMIZE) { mode = nsSizeMode_Minimized; } else { mode = nsSizeMode_Normal; } mOwner->mWidgetListener->SizeModeChanged(mode); } } break; } // A frame window in kiosk/fullscreen mode must have its frame // controls reattached before it's minimized & detached after it's // restored. If this doesn't happen at the correct times, clicking // on the icon won't restore it, the sysmenu will have the wrong // items, and/or the minmax button will have the wrong buttons. case WM_ADJUSTWINDOWPOS: if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) { WinSetParent(mTitleBar, mFrameWnd, TRUE); WinSetParent(mSysMenu, mFrameWnd, TRUE); WinSetParent(mMinMax, mFrameWnd, TRUE); } break; case WM_ADJUSTFRAMEPOS: if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) { WinSetParent(mTitleBar, HWND_OBJECT, TRUE); WinSetParent(mSysMenu, HWND_OBJECT, TRUE); WinSetParent(mMinMax, HWND_OBJECT, TRUE); } break; case WM_DESTROY: DEBUGFOCUS(frame WM_DESTROY); WinSubclassWindow(mFrameWnd, mPrevFrameProc); WinSetWindowPtr(mFrameWnd, QWL_USER, 0); break; case WM_INITMENU: // If we are in fullscreen/kiosk mode, disable maximize menu item. if (mChromeHidden && SHORT1FROMMP(mp1) == SC_SYSMENU && WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { MENUITEM menuitem; WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem)); mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2); WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE); isDone = true; } break; case WM_SYSCOMMAND: // If we are in fullscreen/kiosk mode, don't honor maximize requests. if (mChromeHidden && SHORT1FROMMP(mp1) == SC_MAXIMIZE && WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { isDone = true; } break; // When the frame is activated, set a flag to be acted on after // PM has finished changing focus. When deactivated, dispatch // the event immediately because it doesn't affect the focus. case WM_ACTIVATE: DEBUGFOCUS(WM_ACTIVATE); if (mp1) { mNeedActivation = true; } else { mNeedActivation = false; DEBUGFOCUS(NS_DEACTIVATE); mOwner->DispatchActivationEvent(false); // Prevent the frame from automatically focusing any window // when it's reactivated. Let moz set the focus to avoid // having non-widget children of plugins focused in error. WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0); } break; } if (!isDone) { mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2); } return mresult; }
MRESULT EXPENTRY ObjectWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { BOOL bAutoStart; BOOL bOK; CHAR szTitle[ LEN_WORKSTRING ]; CHAR szWork[ LEN_WORKSTRING ]; FILE *f; HAB hab; HWND hwndToAck; PCHAR pch; PGLOBALS pg; LONG i; LONG cLines; STARTDATA sd; ULONG rc; ULONG ulProcID; ULONG ulSessionID; // store the handle of the window to ack upon task completion; hwndToAck = (HWND)mp1; hab = WinQueryAnchorBlock( hwnd ); switch( msg ) { case WM_CREATE: // mp1 is pointer to globals; save it in object window words pg = (PGLOBALS)mp1; WinSetWindowULong( hwnd, QWL_USER, (ULONG) mp1 ); // start the spooler ? PrfQueryProfileString( HINI_PROFILE, "PM_SPOOLER", "SPOOL", "1;", szWork, LEN_WORKSTRING ); if( *szWork == '1' ) { // assume a bad spooler start pg->fSpooler = FALSE; memset( &sd, 0, sizeof( STARTDATA ) ); sd.Length = sizeof( STARTDATA ); sd.FgBg = 1; // 1=background sd.PgmTitle = "Print Manager"; sd.PgmName = "PMSPOOL.EXE"; sd.PgmInputs = szWork; sd.SessionType = 3; // 3=pm rc = DosStartSession( &sd, &ulSessionID, &ulProcID ); switch( rc ) { case NO_ERROR: // pmspool.exe from 1.3 started ok pg->fSpooler = TRUE; break; default: Spl32QmInitialize( &rc ); pmassert( pg->hab, 0 == rc ); pg->fSpooler = ( 0 == rc ); break; } if( ! pg->fSpooler ) { WinEnableMenuItem( pg->hwndMenubar, IDM_SPOOLER, FALSE ); WinPostMsg( pg->hwndClient, WM_NACK_NO_SPOOLER, 0, 0 ); } } // gather program data by parsing the INI file if( WinSendMsg( hwnd, WM_USER_ADD_PROGRAMS, (MPARAM)hwnd, 0 )) { // start the autostarts for( i = 0; i < pg->cStartem; i++ ) { if( pg->aStartem[ i ].bAutoStart ) { WinSendMsg( hwnd, WM_USER_START, (MPARAM)hwnd, (MPARAM) i ); } } } else { // no ini file WinPostMsg( pg->hwndClient, WM_NACK_NO_INI, 0, 0 ); } return (MRESULT) 0; case WM_USER_ACK: // nop for object window return (MRESULT) 0; case WM_USER_ADD_PROGRAMS: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); // free allocations from the last time for( i = 0; i < pg->cStartem; i++ ) { if( pg->aStartem[ i ].pszTitle ) { free( pg->aStartem[ i ].pszTitle ); pg->aStartem[ i ].pszTitle = NULL; } if( pg->aStartem[ i ].pszCMD ) { free( pg->aStartem[ i ].pszCMD ); pg->aStartem[ i ].pszCMD = NULL; } } // reset how many items are startable pg->cStartem = 0; // open the text ini f = fopen( "\\MSHELL.INI" , "r" ); if( !f ) { // no file WinPostMsg( hwndToAck, WM_NACK_NO_INI, (MPARAM)msg, (MPARAM) FALSE ); return (MPARAM) FALSE; } // disable listbox painting WinEnableWindowUpdate( pg->hwndListbox, FALSE ); // delete all in listbox WinSendMsg( pg->hwndListbox, LM_DELETEALL, 0, 0 ); cLines = 0; i = 0; while( i < LEN_STARTLIST && fgets( szWork, LEN_WORKSTRING, f )) { cLines++; ltrim( trim( szWork )); memset( &(pg->aStartem[ i ]), 0, sizeof( STARTEM )); // comment lines begin with * if( NULL == strchr( "*", *szWork ) && strlen( szWork ) ) { // not a comment and not an empty line. parse it bOK = FALSE; // check for autostart symbol bAutoStart = ('!' == *szWork); if( bAutoStart ) { pch = strchr( szWork, '!' ); pmassert( pg->hab, pch ); *pch = ' '; ltrim( szWork ); } // parse title up to ; pch = strtok( szWork, ";" ); if( pch ) { strcpy( szTitle, pch ); // parse the rest as a CMD start command pch = strtok( NULL, "\n" ); bOK = (BOOL) pch; } // test result of parsing if( bOK ) { pg->aStartem[ i ].bAutoStart = bAutoStart; pg->aStartem[ i ].pszTitle = strdup( szTitle ); pg->aStartem[ i ].pszCMD = strdup( pch ); WinSendMsg( pg->hwndListbox, LM_INSERTITEM, (MPARAM) LIT_END, (MPARAM) pg->aStartem[i].pszTitle ); // bump count of startable items i++; } else { // fire off a nack to elicit a message box; provide line number WinPostMsg( hwndToAck, WM_NACK_SYNTAX_ERROR, (MPARAM)msg, (MPARAM)cLines ); } } } pg->cStartem = i; fclose( f ); if( pg->cStartem > 0 ) { // select the first item WinSendMsg( pg->hwndListbox, LM_SELECTITEM, (MPARAM) 0, (MPARAM) TRUE ); } // let listbox paint itself WinEnableWindowUpdate( pg->hwndListbox, TRUE ); // success WinPostMsg( hwndToAck, WM_USER_ACK, (MPARAM)msg, (MPARAM) TRUE ); return (MRESULT) TRUE; case WM_USER_START: // index of program to start is in mp2 // start an invisible, transient CMD session to handle the stored start command pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); // make, modify a copy of the CMD start command sprintf( szWork, "/c %s", pg->aStartem[ (SHORT)mp2 ].pszCMD ); // a startdata structure for DosStartSession that will start CMD.EXE; // the parameter to CMD is the start command in szWork memset( &sd, 0, sizeof( STARTDATA )); sd.Length = sizeof( STARTDATA ); sd.PgmInputs = szWork; sd.PgmControl = SSF_CONTROL_INVISIBLE; rc = DosStartSession( &sd, &ulSessionID, &ulProcID ); pmassert( hab, rc == 0 || rc == ERROR_SMG_START_IN_BACKGROUND ); WinPostMsg( hwndToAck, WM_USER_ACK, (MPARAM)msg, 0 ); break; case WM_USER_START_CMD: // start CMD in a window; this is default for DosStartSession memset( &sd, 0, sizeof( STARTDATA )); sd.Length = sizeof( STARTDATA ); rc = DosStartSession( &sd, &ulSessionID, &ulProcID ); pmassert( hab, rc == 0 ); WinPostMsg( hwndToAck, WM_USER_ACK, 0, 0 ); break; } // default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); }
MRESULT EXPENTRY FlyWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { SIZEL sizl; int rc, key, mou_r, mou_c, mou_ev, new_vio_rows, new_vio_cols; int deltaX, deltaY, pix_rows, pix_cols, new_x0, new_y0; static int mou_c1=-1, mou_r1=-1; struct _item *L; HWND hwndMenu; SWP swp; QMSG *qmsg; USHORT vk, fl; switch (msg) { case WM_CREATE: hdc = WinOpenWindowDC (hwnd); sizl.cx = sizl.cy = 0; grab_video (); hps = GpiCreatePS (hab, hdc, &sizl, PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC); rc = VioCreatePS (&hvps, 80, 25, 0, 1, 0); VioGetDeviceCellSize (&cyChar, &cxChar, hvps); set_cursor (0); VioSetCurType (pci, hvps); release_video (); DosPostEventSem (hev_VideoReady); return 0; case WM_MOUSEMOVE: mou_ev = MOUEV_MOVE; goto MOUSE; case WM_BUTTON1CLICK: mou_ev = MOUEV_B1SC; goto MOUSE; case WM_BUTTON1DBLCLK: mou_ev = MOUEV_B1DC; goto MOUSE; case WM_BUTTON1MOTIONSTART: mou_ev = MOUEV_B1MS; goto MOUSE; case WM_BUTTON1MOTIONEND: mou_ev = MOUEV_B1ME; goto MOUSE; case WM_BUTTON1DOWN: mou_ev = MOUEV_B1DN; goto MOUSE; case WM_BUTTON1UP: mou_ev = MOUEV_B1UP; goto MOUSE; case WM_BUTTON2CLICK: mou_ev = MOUEV_B2SC; goto MOUSE; case WM_BUTTON2DBLCLK: mou_ev = MOUEV_B2DC; goto MOUSE; case WM_BUTTON2MOTIONSTART: mou_ev = MOUEV_B2MS; goto MOUSE; case WM_BUTTON2MOTIONEND: mou_ev = MOUEV_B2ME; goto MOUSE; case WM_BUTTON2DOWN: mou_ev = MOUEV_B2DN; goto MOUSE; case WM_BUTTON2UP: mou_ev = MOUEV_B2UP; goto MOUSE; case WM_BUTTON3DBLCLK: mou_ev = MOUEV_B3DC; goto MOUSE; case WM_BUTTON3CLICK: mou_ev = MOUEV_B3SC; goto MOUSE; case WM_BUTTON3MOTIONSTART: mou_ev = MOUEV_B3MS; goto MOUSE; case WM_BUTTON3MOTIONEND: mou_ev = MOUEV_B3ME; goto MOUSE; case WM_BUTTON3DOWN: mou_ev = MOUEV_B3DN; goto MOUSE; case WM_BUTTON3UP: mou_ev = MOUEV_B3UP; goto MOUSE; MOUSE: if (fl_opt.mouse_active != TRUE) break; mou_r = vio_rows - 1 - (SHORT2FROMMP (mp1)/cyChar); mou_c = SHORT1FROMMP (mp1)/cxChar; if (mou_r < 0 || mou_c < 0) break; // prevent MOUEV_MOVE message with same coordinates if (mou_ev == MOUEV_MOVE && mou_r == mou_r1 && mou_c == mou_c1) break; mou_r1 = mou_r, mou_c1 = mou_c; que_put (FMSG_BASE_MOUSE + FMSG_BASE_MOUSE_EVTYPE*mou_ev + FMSG_BASE_MOUSE_X*mou_c + FMSG_BASE_MOUSE_Y*mou_r); break; case WM_PAINT: WinBeginPaint (hwnd, hps, NULL); grab_video (); VioShowBuf (0, 2 * vio_rows * vio_cols, hvps); release_video (); WinEndPaint (hps); return 0; case WM_CHAR: if (SHORT1FROMMP (mp1) & KC_KEYUP) return 0; if (SHORT2FROMMP (mp2) == VK_SHIFT || SHORT2FROMMP (mp2) == VK_CTRL || SHORT2FROMMP (mp2) == VK_ALT) return 0; key = pmkey2asvkey (SHORT2FROMMP(mp2), CHAR4FROMMP(mp1), SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), SHORT1FROMMP(mp1)); if (key != -1) que_put (key); return 0; case WM_TRANSLATEACCEL: qmsg = (QMSG *)mp1; vk = SHORT2FROMMP (qmsg->mp2); fl = SHORT1FROMMP (qmsg->mp1) & (KC_ALT | KC_SHIFT | KC_CTRL | KC_KEYUP); if (vk == VK_MENU || vk == VK_F1) return FALSE; //if ((fl & KC_ALT) && vk >= VK_F1 && vk <= VK_F24) return FALSE; break; case WM_CLOSE: que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_QUIT); return 0; case WM_SIZE: if (cxChar != 0 && cyChar != 0) { pix_rows = SHORT2FROMMP (mp2); pix_cols = SHORT1FROMMP (mp2); new_vio_rows = pix_rows / cyChar; new_vio_cols = pix_cols / cxChar; if (new_vio_rows != vio_rows || new_vio_cols != vio_cols) { grab_video (); VioAssociate (0, hvps); VioDestroyPS (hvps); rc = VioCreatePS (&hvps, new_vio_rows, new_vio_cols, 0, 1, 0); VioSetDeviceCellSize (cyChar, cxChar, hvps); VioGetDeviceCellSize (&cyChar, &cxChar, hvps); rc = VioAssociate (hdc, hvps); VioSetCurType (pci, hvps); release_video (); que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_RESIZE + FMSG_BASE_SYSTEM_INT2*new_vio_rows + FMSG_BASE_SYSTEM_INT1*new_vio_cols); } deltaX = new_vio_cols*cxChar - pix_cols; deltaY = new_vio_rows*cyChar - pix_rows; //if (deltaX != 0 || deltaY != 0) if (abs(deltaX) > MAX_DELTA || abs(deltaY) > MAX_DELTA) { WinPostMsg (hwndFrame, WM_FLY_RESIZE, MPFROM2SHORT (SHORTBASE+deltaX, SHORTBASE+deltaY), NULL); } } WinDefAVioWindowProc (hwnd, msg, (ULONG)mp1, (ULONG)mp2); return 0; case WM_COMMAND: que_put (FMSG_BASE_MENU + LOUSHORT (mp1)); break; case WM_FLY_LOADMENU: L = PVOIDFROMMP (mp1); // obtain handle for window menu hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); fill_submenu (hwndMenu, L); fly_active_menu = L; break; case WM_FLY_UNLOADMENU: L = PVOIDFROMMP (mp1); // obtain handle for window menu hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); empty_submenu (hwndMenu, L); fly_active_menu = NULL; break; case WM_FLY_RESIZE: deltaX = SHORT1FROMMP (mp1) - SHORTBASE; deltaY = SHORT2FROMMP (mp1) - SHORTBASE; rc = WinQueryWindowPos (hwndFrame, &swp); rc = WinSetWindowPos (hwndFrame, 0, swp.x, swp.y-deltaY, swp.cx+deltaX, swp.cy+deltaY, SWP_SIZE|SWP_MOVE); break; case WM_FLY_MOVE_CANVAS: new_x0 = SHORT1FROMMP (mp1) - SHORTBASE; new_y0 = SHORT2FROMMP (mp1) - SHORTBASE; rc = WinQueryWindowPos (hwndFrame, &swp); WinSetWindowPos (hwndFrame, 0, new_x0, new_y0-swp.cy, 0, 0, SWP_MOVE); //DosPostEventSem (hev_VideoReady); break; case WM_FLY_MENU_CHSTATUS: hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); WinEnableMenuItem (hwndMenu, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); item_status_change++; break; case WM_FLY_MENU_CHSTATE: hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (SHORT1FROMMP(mp1), TRUE), MPFROM2SHORT (MIA_CHECKED, SHORT2FROMMP(mp1) ? MIA_CHECKED : 0)); break; case WM_DESTROY: grab_video (); VioAssociate (0, hvps); VioDestroyPS (hvps); GpiDestroyPS (hps); release_video (); que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_DIE); return 0; } return WinDefWindowProc (hwnd, msg, mp1, mp2); }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static HAB hab ; static HWND hwndMenu ; static INT iCurrentRep = IDM_10 ; static INT iStatus = STATUS_READY ; static LONG lCalcRep, lRepAmts [] = { 10, 100, 1000, 10000, 100000 } ; static ULONG ulElapsedTime ; double A ; LONG lRep ; switch (msg) { case WM_CREATE: hab = WinQueryAnchorBlock (hwnd) ; hwndMenu = WinWindowFromID ( WinQueryWindow (hwnd, QW_PARENT), FID_MENU) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_10: case IDM_100: case IDM_1000: case IDM_10000: case IDM_100000: WinCheckMenuItem (hwndMenu, iCurrentRep, FALSE) ; iCurrentRep = COMMANDMSG(&msg)->cmd ; WinCheckMenuItem (hwndMenu, iCurrentRep, TRUE) ; return 0 ; case IDM_START: WinEnableMenuItem (hwndMenu, IDM_START, FALSE) ; WinEnableMenuItem (hwndMenu, IDM_ABORT, TRUE) ; iStatus = STATUS_WORKING ; WinInvalidateRect (hwnd, NULL, FALSE) ; WinUpdateWindow (hwnd) ; WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE)) ; if (WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT) == 0) WinShowPointer (HWND_DESKTOP, TRUE) ; lCalcRep = lRepAmts [iCurrentRep - IDM_10] ; ulElapsedTime = WinGetCurrentTime (hab) ; for (A = 1.0, lRep = 0 ; lRep < lCalcRep ; lRep++) A = Savage (A) ; ulElapsedTime = WinGetCurrentTime (hab) - ulElapsedTime ; if (WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT) == 0) WinShowPointer (HWND_DESKTOP, FALSE) ; WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, FALSE)) ; iStatus = STATUS_DONE ; WinInvalidateRect (hwnd, NULL, FALSE) ; WinUpdateWindow (hwnd) ; WinEnableMenuItem (hwndMenu, IDM_START, TRUE) ; WinEnableMenuItem (hwndMenu, IDM_ABORT, FALSE) ; return 0 ; case IDM_ABORT: // Not much we can do here return 0 ; } break ; case WM_PAINT: PaintWindow (hwnd, iStatus, lCalcRep, ulElapsedTime) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
// Process messages from the frame MRESULT nsFrameWindow::FrameMessage( ULONG msg, MPARAM mp1, MPARAM mp2) { MRESULT mresult = 0; BOOL bDone = FALSE; switch (msg) { case WM_WINDOWPOSCHANGED: { PSWP pSwp = (PSWP) mp1; // Note that client windows never get 'move' messages (well, they won't here anyway) if( pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE)) { // These commented-out `-1's cancel each other out. POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy /* - 1 */ }; ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y /* - 1*/ ; mBounds.x = ptl.x; mBounds.y = ptl.y; OnMove( ptl.x, ptl.y); } // When the frame is sized, do stuff to recalculate client size. if( pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE)) { mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2); bDone = TRUE; mBounds.width = pSwp->cx; mBounds.height = pSwp->cy; UpdateClientSize(); DispatchResizeEvent( mSizeClient.width, mSizeClient.height); } if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) { nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this); if (pSwp->fl & SWP_MAXIMIZE) event.mSizeMode = nsSizeMode_Maximized; else if (pSwp->fl & SWP_MINIMIZE) event.mSizeMode = nsSizeMode_Minimized; else event.mSizeMode = nsSizeMode_Normal; InitEvent(event); DispatchWindowEvent(&event); } break; } // a frame window in kiosk/fullscreen mode must have its frame // controls reattached before it's minimized & detached after it's // restored; if this doesn't happen at the correct times, clicking // on the icon won't restore it, the sysmenu will have the wrong // items, and/or the minmax button will have the wrong buttons case WM_ADJUSTWINDOWPOS: { if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) { HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax"); if (hwndTemp) WinSetParent(hwndTemp, mFrameWnd, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar"); if (hwndTemp) WinSetParent(hwndTemp, mFrameWnd, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu"); if (hwndTemp) WinSetParent(hwndTemp, mFrameWnd, TRUE); } break; } case WM_ADJUSTFRAMEPOS: { if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) { HWND hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndSysMenu"); if (hwndTemp) WinSetParent(hwndTemp, HWND_OBJECT, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndTitleBar"); if (hwndTemp) WinSetParent(hwndTemp, HWND_OBJECT, TRUE); hwndTemp = (HWND)WinQueryProperty(mFrameWnd, "hwndMinMax"); if (hwndTemp) WinSetParent(hwndTemp, HWND_OBJECT, TRUE); } break; } case WM_DESTROY: DEBUGFOCUS(frame WM_DESTROY); WinSubclassWindow( mFrameWnd, fnwpDefFrame); WinSetWindowPtr( mFrameWnd, QWL_USER, 0); WinRemoveProperty(mFrameWnd, "hwndTitleBar"); WinRemoveProperty(mFrameWnd, "hwndSysMenu"); WinRemoveProperty(mFrameWnd, "hwndMinMax"); WinRemoveProperty(mFrameWnd, "ulStyle"); break; case WM_INITMENU: /* If we are in fullscreen/kiosk mode, disable maximize menu item */ if (mChromeHidden) { if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { if (SHORT1FROMMP(mp1) == SC_SYSMENU) { MENUITEM menuitem; WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem)); mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2); WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE); bDone = TRUE; } } } break; case WM_SYSCOMMAND: /* If we are in fullscreen/kiosk mode, don't honor maximize requests */ if (mChromeHidden) { if (WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) { if ((SHORT1FROMMP(mp1) == SC_MAXIMIZE)) { bDone = TRUE; } } } break; // When the frame is activated, set a flag to be acted on after // PM has finished changing focus. When deactivated, dispatch // the event immediately because it doesn't affect the focus. case WM_ACTIVATE: DEBUGFOCUS(WM_ACTIVATE); if (mp1) { mNeedActivation = PR_TRUE; } else { mNeedActivation = PR_FALSE; DEBUGFOCUS(NS_DEACTIVATE); DispatchFocus(NS_DEACTIVATE); // Prevent the frame from automatically focusing any window // when it's reactivated. Let moz set the focus to avoid // having non-widget children of plugins focused in error. WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0); } break; } if( !bDone) mresult = (*fnwpDefFrame)( mFrameWnd, msg, mp1, mp2); return mresult; }
MRESULT EXPENTRY SwapProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { static HWND hwndMenu = (HWND)0; switch(msg) { case WM_CREATE: { MRESULT mr = PFNWPStatic(hwnd,msg,mp1,mp2); WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID); return mr; } case WM_MOUSEMOVE: break; case WM_PRESPARAMCHANGED: { char *rootname = "SwapMon"; switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case CLOCK_FRAME: rootname = "Clock"; break; case HARD_FRAME: rootname = "Hard"; break; case CPU_FRAME: rootname = "CPU"; break; case CLP_FRAME: rootname = "ClipMon"; break; case MEM_FRAME: rootname = "Mem"; break; case TSK_FRAME: rootname = "Task"; break; } PresParamChanged(hwnd, rootname, mp1, mp2); PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); PostMsg(hwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); } break; case WM_APPTERMINATENOTIFY: if(WinQueryWindowUShort(hwnd,QWS_ID) == CPU_FRAME) { if(!StartCPUThreads()) WinDestroyWindow(hwnd); } break; case WM_BUTTON1MOTIONSTART: { POINTL ptl; ptl.x = SHORT1FROMMP(mp1); ptl.y = SHORT2FROMMP(mp1); WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1L); PostMsg(hwndConfig, UM_SHOWME, MPFROM2SHORT((USHORT)ptl.x,(USHORT)ptl.y), mp2); } return MRFROMSHORT(TRUE); case WM_BUTTON2MOTIONSTART: { TRACKINFO TrackInfo; SWP Position; memset(&TrackInfo,0,sizeof(TrackInfo)); TrackInfo.cxBorder = 1 ; TrackInfo.cyBorder = 1 ; TrackInfo.cxGrid = 1 ; TrackInfo.cyGrid = 1 ; TrackInfo.cxKeyboard = 8 ; TrackInfo.cyKeyboard = 8 ; WinQueryWindowPos(hwnd,&Position); TrackInfo.rclTrack.xLeft = Position.x ; TrackInfo.rclTrack.xRight = Position.x + Position.cx ; TrackInfo.rclTrack.yBottom = Position.y ; TrackInfo.rclTrack.yTop = Position.y + Position.cy ; WinQueryWindowPos(HWND_DESKTOP,&Position); TrackInfo.rclBoundary.xLeft = Position.x ; TrackInfo.rclBoundary.xRight = Position.x + Position.cx ; TrackInfo.rclBoundary.yBottom = Position.y ; TrackInfo.rclBoundary.yTop = Position.y + Position.cy ; TrackInfo.ptlMinTrackSize.x = 0 ; TrackInfo.ptlMinTrackSize.y = 0 ; TrackInfo.ptlMaxTrackSize.x = Position.cx ; TrackInfo.ptlMaxTrackSize.y = Position.cy ; TrackInfo.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY ; if(WinTrackRect(HWND_DESKTOP, (HPS)0, &TrackInfo)) { WinSetWindowPos(hwnd, HWND_TOP, TrackInfo.rclTrack.xLeft, TrackInfo.rclTrack.yBottom, 0, 0, SWP_MOVE); switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case SWAP_FRAME: WinQueryWindowPos(hwnd,&swpSwap); SavePrf("SwapSwp", &swpSwap, sizeof(SWP)); break; case CLOCK_FRAME: WinQueryWindowPos(hwnd,&swpClock); SavePrf("ClockSwp", &swpClock, sizeof(SWP)); break; case HARD_FRAME: WinQueryWindowPos(hwnd,&swpHard); SavePrf("HardSwp", &swpHard, sizeof(SWP)); break; case CPU_FRAME: WinQueryWindowPos(hwnd,&swpCPU); SavePrf("CPUSwp", &swpCPU, sizeof(SWP)); break; case CLP_FRAME: WinQueryWindowPos(hwnd,&swpClip); SavePrf("ClipSwp", &swpClip, sizeof(SWP)); break; case MEM_FRAME: WinQueryWindowPos(hwnd,&swpMem); SavePrf("MemSwp", &swpMem, sizeof(SWP)); break; case TSK_FRAME: WinQueryWindowPos(hwnd,&swpTask); SavePrf("TaskSwp", &swpTask, sizeof(SWP)); break; } } } return MRFROMSHORT(TRUE); case WM_BUTTON1DOWN: WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); return MRFROMSHORT(TRUE); case WM_BUTTON1DBLCLK: case WM_BUTTON1CLICK: if((!fNoMonClick && msg == WM_BUTTON1CLICK) || (fNoMonClick && msg == WM_BUTTON1DBLCLK)) { switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case HARD_FRAME: { ULONG ulDriveNum,ulDriveMap,x; ulDriveMon = min(ulDriveMon,26); if(!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { for(x = ulDriveMon + 1;x < 26;x++) { if(ulDriveMap & (1 << x)) { ulDriveMon = x; break; } } if(x >= 26) { for(x = 3;x < ulDriveMon - 1;x++) { if(ulDriveMap & (1 << x)) { ulDriveMon = x; break; } } } SavePrf("MonDrive", &ulDriveMon, sizeof(ULONG)); } PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); } break; case CLP_FRAME: case MEM_FRAME: case TSK_FRAME: case SWAP_FRAME: case CLOCK_FRAME: case CPU_FRAME: { USHORT cmd = CPU_PULSE; switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case MEM_FRAME: cmd = CLOCK_CMDLINE; break; case TSK_FRAME: cmd = CPU_KILLPROC; break; case CLP_FRAME: cmd = CLOCK_CLIPBOARD; break; case SWAP_FRAME: cmd = SWAP_LAUNCHPAD; break; case CLOCK_FRAME: cmd = CLOCK_SETTINGS; if((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0) cmd = CLOCK_CLOCK; break; } PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd,0), MPVOID); } break; } return MRFROMSHORT(TRUE); } else PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); break; case WM_CONTEXTMENU: WinInvalidateRect(hwnd, NULL, FALSE); WinSendMsg(hwnd, UM_TIMER, MPVOID, MPVOID); WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); { USHORT id; id = WinQueryWindowUShort(hwnd,QWS_ID); hwndMenu = WinLoadMenu(HWND_DESKTOP, 0, id); if(hwndMenu) { POINTL ptl; SWP swp; ULONG ulDriveNum,ulDriveMap,x; MENUITEM mi; char s[80]; SetPresParams(hwndMenu, -1, -1, -1, helvtext); switch(id) { case CLP_FRAME: WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(CLP_APPEND,FALSE), MPFROM2SHORT(MIA_CHECKED, ((fClipAppend) ? MIA_CHECKED : 0))); break; case HARD_FRAME: if(!DosQCurDisk(&ulDriveNum, &ulDriveMap)) { mi.iPosition = 0; mi.hwndSubMenu = (HWND)0; mi.hItem = 0L; mi.afStyle = MIS_TEXT | MIS_STATIC; mi.afAttribute = MIA_FRAMED; mi.id = -1; sprintf(s, "Current drive is %c:", (char)(ulDriveMon + '@')); WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s)); mi.iPosition = MIT_END; for(x = 2;x < 26;x++) { if(ulDriveMap & (1 << x)) { if(x != ulDriveMon - 1) { mi.afStyle = MIS_TEXT; mi.afAttribute = 0; mi.id = HARD_C + (x - 2); if(fShowFreeInMenus) SetDriveText(x + 1, s); else sprintf(s, "%c:", (char)(x + 'A')); WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s)); } } } } break; case CLOCK_FRAME: WinEnableMenuItem(hwndMenu, CLOCK_VIRTUAL, fDesktops); WinEnableMenuItem(hwndMenu, CLOCK_CLIPBOARD, (ClipHwnd != (HWND)0)); break; default: break; } WinQueryWindowPos(hwnd, &swp); ptl.x = SHORT1FROMMP(mp1); ptl.y = SHORT2FROMMP(mp1); WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1L); ptl.y = max(ptl.y,swp.y + swp.cy + 4); if(!WinPopupMenu(HWND_DESKTOP, hwnd, hwndMenu, ptl.x - 4, ptl.y - 4, 0, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1)) { WinDestroyWindow(hwndMenu); hwndMenu = (HWND)0; } } } return MRFROMSHORT(TRUE); case WM_MENUEND: WinSetFocus(HWND_DESKTOP, HWND_DESKTOP); WinDestroyWindow((HWND)mp2); if(hwndMenu == (HWND)mp2) hwndMenu = (HWND)0; return 0; case UM_SETUP: { char *rootname = "SwapMon"; switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case SWAP_FRAME: SwapHwnd = hwnd; swaptick = 0; break; case CLOCK_FRAME: ClockHwnd = hwnd; rootname = "Clock"; break; case TSK_FRAME: TaskHwnd = hwnd; rootname = "Task"; break; case MEM_FRAME: MemHwnd = hwnd; rootname = "Mem"; break; case HARD_FRAME: HardHwnd = hwnd; rootname = "Hard"; break; case CPU_FRAME: CPUHwnd = hwnd; rootname = "CPU"; PostMsg(hwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); break; case CLP_FRAME: ClipMonHwnd = hwnd; rootname = "ClipMon"; PostMsg(hwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); break; } if(!RestorePresParams(hwnd,rootname)) SetPresParams(hwnd, RGB_WHITE, RGB_BLACK, RGB_BLACK, helvtext); } PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); return 0; case UM_REFRESH: switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case CLP_FRAME: { char s[] = " Clip: [TtBbMmP] + ",*p; ULONG fmt[] = {CF_TEXT,CF_DSPTEXT, CF_BITMAP,CF_DSPBITMAP, CF_METAFILE,CF_DSPMETAFILE, CF_PALETTE,0}; ULONG x,ret; if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) { p = s + 8; for(x = 0;fmt[x];x++) { ret = WinQueryClipbrdData(WinQueryAnchorBlock(hwnd), fmt[x]); if(!ret) *p = '-'; p++; } p += 2; if(!fClipAppend) *p = 0; WinCloseClipbrd(WinQueryAnchorBlock(hwnd)); } else strcpy(s + 7, "Can't open. "); SetMonitorSize(hwnd, hwndMenu, &swpClip, s); } break; case CPU_FRAME: { char s[32]; ULONG percent,lastaverage; static BOOL lastavgset = 0; *s = 0; if(mp2) { strcpy(s," CPU: -% "); if(fAverage) strcat(s,"Avg: -%) "); } else { percent = ((MaxCount - (ULONG)mp1) * 100) / MaxCount; lastaverage = AveCPU; AveCPU = (((AveCPU * NumAveCPU) + percent) / ((ULONG)NumAveCPU + 1)); NumAveCPU++; if(!NumAveCPU) NumAveCPU = 65535; if(percent != LastPercent || (AveCPU != lastaverage && fAverage) || NumAveCPU == 1 || lastavgset != fAverage) { lastavgset = fAverage; LastPercent = percent; sprintf(s, " CPU: %lu%% ", percent); if(fAverage) sprintf(s + strlen(s), "(Avg: %lu%%) ", AveCPU); } } if(*s) SetMonitorSize(hwnd, hwndMenu, &swpCPU, s); } break; } return 0; case WM_TIMER: if(fSwapFloat && !hwndMenu) WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_SHOW); if(WinQueryWindowUShort(hwnd,QWS_ID) == CLP_FRAME) { if(!ClipHwnd) WinDestroyWindow(hwnd); else TakeClipboard(); } return 0; case UM_TIMER: switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case CLP_FRAME: ClipMonHwnd = hwnd; WinSendMsg(hwnd, WM_TIMER, MPVOID, MPVOID); break; case CPU_FRAME: CPUHwnd = hwnd; WinSendMsg(hwnd, WM_TIMER, MPVOID, MPVOID); break; case HARD_FRAME: { char s[80]; HardHwnd = hwnd; SetDriveText(ulDriveMon, s); SetMonitorSize(hwnd, hwndMenu, &swpHard, s); } break; case SWAP_FRAME: { FILEFINDBUF3 ffb; ULONG nm = 1,fl = SWP_SIZE | SWP_SHOW | SWP_MOVE, sh,sl,nh; HDIR hdir = HDIR_CREATE; FSALLOCATE fsa; char s[128],ss[8],sss[8],mb,smb; static ULONG lastcbFile = 0; static BOOL warned = FALSE; static char SwapperDat[CCHMAXPATH] = ""; strcpy(s, " Unable to locate SWAPPER.DAT. "); SwapHwnd = hwnd; if(!*SwapperDat) FindSwapperDat(SwapperDat); if(*SwapperDat) { DosError(FERR_DISABLEHARDERR); if(!DosFindFirst(SwapperDat, &hdir, FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY, &ffb, sizeof(ffb), &nm, FIL_STANDARD)) { DosFindClose(hdir); if(ffb.cbFile != lastcbFile && lastcbFile) swaptick = 9; lastcbFile = ffb.cbFile; DosError(FERR_DISABLEHARDERR); if(!DosQueryFSInfo(toupper(*SwapperDat) - '@', FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) nm = fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector); else nm = 0; if(nm <= 32768 * 1024) { swaptick = 10; if(!warned) { SetPresParams(hwnd, RGB_RED, -1, -1, NULL); warned = TRUE; DosBeep(250,15); } } else if(warned) { PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); warned = FALSE; } mb = MakeNumber(nm, &nh, &sl); *sss = 0; if(sl) sprintf(sss, ".%02lu", sl); smb = MakeNumber(ffb.cbFile, &sh, &sl); *ss = 0; if(sl) sprintf(ss, ".%02lu", sl); sprintf(s, " Swap: %lu%s%cb ", sh, ss, smb); if(fShowSwapFree) sprintf(s + strlen(s), "(%lu%s%cb free) ", nh, sss, mb); } } SetMonitorSize(hwnd, hwndMenu, &swpSwap, s); } break; case TSK_FRAME: { PROCESSINFO *ppi; BUFFHEADER *pbh = NULL; MODINFO *pmi; long numprocs = -1,numthreads = -1; char s[80]; if(!DosAllocMem((PVOID)&pbh, USHRT_MAX + 4096, PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) { if(!DosQProcStatus(pbh, USHRT_MAX)) { numprocs = numthreads = 0; ppi = pbh->ppi; while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) { pmi = pbh->pmi; while(pmi && ppi->hModRef != pmi->hMod) pmi = pmi->pNext; if(pmi) { numprocs++; numthreads += ppi->usThreadCount; } ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount); } } DosFreeMem(pbh); sprintf(s, " Procs: %ld Thrds: %ld ", numprocs, numthreads); SetMonitorSize(hwnd, hwndMenu, &swpTask, s); } } break; case MEM_FRAME: { ULONG sh,sl,nh,amem; char s[128],ss[8],sss[8],mb,smb; strcpy(s, "Can't check virtual memory."); MemHwnd = hwnd; if(!DosQuerySysInfo(QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &amem, sizeof(amem))) { mb = MakeNumber(amem, &nh, &sl); *ss = 0; if(sl) sprintf(ss, ".%02lu", sl); sprintf(s, " VMem: %lu%s%cb ", nh, ss, mb); } if(fShowPMem) { if(!Dos16MemAvail(&amem)) { mb = MakeNumber(amem, &nh, &sl); *ss = 0; if(sl) sprintf(ss, ".%02lu", sl); sprintf(s + strlen(s), " PMem: %lu%s%cb ", nh, ss, mb); } } SetMonitorSize(hwnd, hwndMenu, &swpMem, s); } break; case CLOCK_FRAME: { char s[80]; DATETIME dt; ClockHwnd = hwnd; if(!DosGetDateTime(&dt)) { sprintf(s, " %0*u:%02u%s ", ((ampm) ? 0 : 2), (dt.hours % ((ampm) ? 12 : 24)) + ((ampm && !(dt.hours % 12)) ? 12 : 0), dt.minutes, ((ampm) ? (dt.hours > 11) ? "pm" : "am" : "")); if(showdate) sprintf(s + strlen(s), "%02u/%02u ", dt.month, dt.day); } else strcpy(s,"Unknown time"); SetMonitorSize(hwnd, hwndMenu, &swpClock, s); } break; } return 0; case WM_COMMAND: { BOOL ctrl,shift; ctrl = ((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0); shift = ((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0); switch(SHORT1FROMMP(mp1)) { case CLP_CLEAR: if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) { WinEmptyClipbrd(WinQueryAnchorBlock(hwnd)); WinCloseClipbrd(WinQueryAnchorBlock(hwnd)); PostMsg(hwnd, UM_REFRESH, MPVOID, MPVOID); } break; case CLP_APPEND: fClipAppend = (fClipAppend) ? FALSE : TRUE; SavePrf("ClipAppend", &fClipAppend, sizeof(BOOL)); PostMsg(hwnd, UM_REFRESH, MPVOID, MPVOID); if(ClipSetHwnd) PostMsg(ClipSetHwnd, UM_REFRESH, MPVOID, MPVOID); break; case MSE_HELP: ViewHelp(hwnd, "Monitors page"); break; case CPU_PULSE: { PROGDETAILS pgd; WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_FOCUSACTIVATE); memset(&pgd, 0, sizeof(pgd)); pgd.Length = sizeof(pgd); pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER; pgd.swpInitial.hwndInsertBehind = HWND_TOP; pgd.progt.fbVisible = SHE_VISIBLE; pgd.progt.progc = PROG_DEFAULT; pgd.pszExecutable = "PULSE.EXE"; if(WinStartApp(CPUHwnd, &pgd, NULL, NULL, 0)) { if(CPUHwnd) { closethreads = 1; DosSleep(1); PostMsg(CPUHwnd, UM_REFRESH, MPVOID, MPFROMSHORT(TRUE)); } } } break; case CPU_RESET: AveCPU = 0; NumAveCPU = 0; break; case CLOCK_VIRTUAL: case CLOCK_SWITCHLIST: case CLOCK_CMDLINE: case CLOCK_CLIPBOARD: case CLOCK_CALCULATOR: case HARD_FM2: case MSE_FRAME: { ULONG msg2 = UM_SHOWME; MPARAM mp12 = 0,mp22 = 0; HWND hwndP = hwndConfig; switch(SHORT1FROMMP(mp1)) { case CLOCK_CMDLINE: mp12 = MPFROMLONG(((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0)); msg2 = UM_CMDLINE; break; case CLOCK_CLIPBOARD: msg2 = UM_CLIPMGR; hwndP = ObjectHwnd3; break; case CLOCK_SWITCHLIST: msg2 = UM_SWITCHLIST; break; case CLOCK_VIRTUAL: msg2 = UM_VIRTUAL; break; case CLOCK_CALCULATOR: msg2 = UM_CALC; break; case HARD_FM2: msg2 = UM_STARTWIN; mp12 = MPFROM2SHORT(C_STARTFM2,0); break; } PostMsg(hwndP, msg2, mp12, mp22); } break; case CLOCK_SETTINGS: case CLOCK_CLOCK: case SWAP_LAUNCHPAD: case SWAP_WARPCENTER: case SWAP_CONNECTIONS: case SWAP_INFO: case SWAP_SETTINGS: case SWAP_SYSTEM: case SWAP_TEMPS: case SWAP_FM2: case HARD_OPEN: case CVR_COLORPALETTE: case CVR_HICOLORPALETTE: case CVR_FONTPALETTE: case CPU_KILLPROC: case CPU_HARDWARE: { char *p = "<WP_CLOCK>",*pp = defopen; char s[8]; switch(SHORT1FROMMP(mp1)) { case HARD_OPEN: sprintf(s, "%c:\\", (char)(ulDriveMon + '@')); p = s; break; case SWAP_FM2: p = "<FM3_Folder>"; break; case SWAP_TEMPS: p = "<WP_TEMPS>"; break; case SWAP_SYSTEM: p = "<WP_OS2SYS>"; break; case SWAP_SETTINGS: p = "<WP_CONFIG>"; break; case SWAP_INFO: p = "<WP_INFO>"; break; case SWAP_CONNECTIONS: p = "<WP_CONNECTIONSFOLDER>"; break; case SWAP_WARPCENTER: p = "<WP_WARPCENTER>"; break; case SWAP_LAUNCHPAD: p = "<WP_LAUNCHPAD>"; break; case CLOCK_SETTINGS: pp = setopen; break; case CVR_COLORPALETTE: p = "<WP_LORESCLRPAL>"; break; case CVR_HICOLORPALETTE: p = "<WP_HIRESCLRPAL>"; break; case CVR_FONTPALETTE: p = "<WP_FNTPAL>"; break; case CPU_KILLPROC: p = "<FM/2_KILLPROC>"; break; case CPU_HARDWARE: p = "<WP_HWMGR>"; break; } OpenObject(p, pp); } break; case HARD_VDIR: { PROGDETAILS pgd; char s[36]; sprintf(s, "/C VDIR.CMD %c:\\", (char)(ulDriveMon + '@')); memset(&pgd, 0, sizeof(pgd)); pgd.Length = sizeof(pgd); pgd.swpInitial.fl = SWP_MINIMIZE | SWP_ACTIVATE | SWP_ZORDER; pgd.swpInitial.hwndInsertBehind = HWND_TOP; pgd.progt.fbVisible = SHE_VISIBLE; pgd.progt.progc = PROG_DEFAULT; pgd.pszExecutable = "CMD.EXE"; WinStartApp((HWND)0, &pgd, s, NULL, 0); } break; case HARD_CHKDSK: { PROGDETAILS pgd; char s[8]; WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_FOCUSACTIVATE); sprintf(s, "%c:", (char)(ulDriveMon + '@')); memset(&pgd, 0, sizeof(pgd)); pgd.Length = sizeof(pgd); pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER; pgd.swpInitial.hwndInsertBehind = HWND_TOP; pgd.progt.fbVisible = SHE_VISIBLE; pgd.progt.progc = PROG_DEFAULT; pgd.pszExecutable = "PMCHKDSK.EXE"; WinStartApp((HWND)0, &pgd, s, NULL, 0); } break; default: if(SHORT1FROMMP(mp1) >= HARD_C && SHORT1FROMMP(mp1) <= HARD_C + 24) { ulDriveMon = (SHORT1FROMMP(mp1) - HARD_C) + 3; PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID); if(ctrl) PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(HARD_OPEN,0), MPVOID); else if(shift) PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(HARD_VDIR,0), MPVOID); } break; } } return 0; case WM_DESTROY: switch(WinQueryWindowUShort(hwnd,QWS_ID)) { case SWAP_FRAME: SwapHwnd = (HWND)0; break; case CLOCK_FRAME: ClockHwnd = (HWND)0; break; case HARD_FRAME: HardHwnd = (HWND)0; break; case CPU_FRAME: closethreads = 1; DosSleep(1); CPUHwnd = (HWND)0; break; case CLP_FRAME: ClipMonHwnd = (HWND)0; break; case MEM_FRAME: MemHwnd = (HWND)0; break; case TSK_FRAME: TaskHwnd = (HWND)0; break; } break; } return PFNWPStatic(hwnd,msg,mp1,mp2); }
// exported extern windows callback routine (doet alle belangrijke stuff) MRESULT EXPENTRY ClientWndProc(HWND hwnd,ULONG messg,MPARAM mp1,MPARAM mp2) { HPS hps; static HWND hMenu; RECTL rc; static INT xView, yView; int count,zoom,tel; float tmpangle; BOOL stat; SIZEL sizel; POINTL ptl; switch (messg) { case DM_CHECKSCORE: count = check_hiscores(mp1); if (count != 10) { WinDlgBox(HWND_DESKTOP,hwnd,EnterHiScore,NULLHANDLE,DRIFT_HISCORE,NULL); if (glb_name[0] == 0) strcpy(HiTable[count].name,"Cthulhu"); else strcpy(HiTable[count].name,glb_name); } break; case WM_SIZE: xView = SHORT1FROMMP(mp2); yView = SHORT2FROMMP(mp2); break; case WM_CREATE: init_logo(); load_hiscores(); // initialize the settings //hMenu=WinQueryWindow(hwnd,QW_PARENT); hMenu=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_MENU); // uncheck detaillevel stat = WinCheckMenuItem(hMenu,detaillevel,FALSE); // uncheck save on exit stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE); load_settings(); // check to correct menu item detaillevel stat = WinCheckMenuItem(hMenu,detaillevel,TRUE); if (saveonexit) stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE); switch (detaillevel) { case IDM_HIGHDET: game_bigex = 36; game_mediumex = 18; game_smallex = 9; maxthrustpixels = 9; break; case IDM_MEDIUMDET: game_bigex = 18; game_mediumex = 18; game_smallex = 9; maxthrustpixels = 5; break; case IDM_LOWDET: game_bigex = 9; game_mediumex = 9; game_smallex = 9; maxthrustpixels = 3; break; } if (saveonexit == TRUE) stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE); else stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE); break; case WM_TIMER: hps = WinGetPS(hwnd) ; sizel.cx = 2000 ; sizel.cy = 2000 ; GpiSetPS (hps, &sizel, PU_PELS) ; GpiQueryPageViewport(hps,&rc); rc.xLeft = 0;//xView / 2 ; rc.xRight = xView ; rc.yBottom = 0;//yView / 2 ; rc.yTop = yView; GpiSetPageViewport (hps, &rc) ; switch (game_status) { case GAME_INTRO : stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE); stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE); stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE); zoom = (game_duration - 100)/3; if (zoom < 5) zoom = 5; D->angle += 10; D->zoom = zoom; R->angle += 10; R->zoom = zoom; I->angle += 10; I->zoom = zoom; F->angle += 10; F->zoom = zoom; T->angle += 10; T->zoom = zoom; game_duration --; if (game_duration == 0) { game_status = GAME_HISCORE; game_duration = 200; if (random(2) == 0) { // insert the hiscore table insert_message(1800,0,"D R I F T F O R O S / 2 H I S C O R E S"); insert_message(1600,0,"Rank Name Score Level"); for (tel = 0; tel < 10; tel++) insert_message(1460-(tel*100),0,"%2d %-12s %5d %2d",tel+1,HiTable[tel].name,HiTable[tel].score,HiTable[tel].level); } else { // insert help message insert_message(1800,0,"DRIFT WARPSPEED FOR OS/2 WARP"); insert_message(1600,0,"By Dirk Vandenheuvel /c/ 1995"); insert_message(1400,0,"Keys"); insert_message(1200,0,"UP Thrust"); insert_message(1100,0,"LEFT Turn left"); insert_message(1000,0,"RIGHT Turn right"); insert_message(900,0, "SPACE Fire missile"); } WinInvalidateRect(hwnd,NULL,TRUE); } else intro(hps); break; case GAME_HISCORE: game_duration --; if (game_duration == 0) { // free the effekts list free_all(); game_status = GAME_INTRO; game_duration = 200; WinInvalidateRect(hwnd,NULL,TRUE); } break; case GAME_PLAYING: // play check_keys(); if (game_shooting) game_shooting--; game(hps); break; } WinReleasePS(hps); break; case WM_SYSCOMMAND: /*switch(mp1) { case SC_MINIMIZE: if (!game_pauze) SendMessage(hwnd,WM_COMMAND,IDM_PAUZE,0); break; } return(DefWindowProc(hwnd,messg,mp1,mp2));*/ break; case WM_COMMAND: switch (COMMANDMSG(&messg)->cmd) { case IDM_SAVEONEXIT: if (saveonexit == TRUE) // already checked { stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE); saveonexit = FALSE; save_settings(); // save the "do not save on exit" setting } else { stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE); saveonexit = TRUE; } break; case IDM_HIGHDET : // set to high game_bigex = 36; game_mediumex = 18; game_smallex = 9; maxthrustpixels = 9; stat = WinCheckMenuItem(hMenu,detaillevel,FALSE); detaillevel=SHORT1FROMMP(mp1); stat = WinCheckMenuItem(hMenu,detaillevel,TRUE); break; case IDM_MEDIUMDET: game_bigex = 18; game_mediumex = 18; game_smallex = 9; maxthrustpixels = 5; stat = WinCheckMenuItem(hMenu,detaillevel,FALSE); detaillevel=SHORT1FROMMP(mp1); stat = WinCheckMenuItem(hMenu,detaillevel,TRUE); break; case IDM_LOWDET: game_bigex = 9; game_mediumex = 9; game_smallex = 9; maxthrustpixels = 3; stat = WinCheckMenuItem(hMenu,detaillevel,FALSE); detaillevel=SHORT1FROMMP(mp1); stat = WinCheckMenuItem(hMenu,detaillevel,TRUE); break; case IDM_ABOUT: WinDlgBox(HWND_DESKTOP,hwnd,AboutDiaProc,NULLHANDLE,IDD_ABOUT,NULL); break; case IDM_HELP : //WinHelp (hwnd,"drift.hlp",HELP_INDEX,0); break; case IDVK_ESCAPE: // escape key pressed //SendMessage (hwnd, WM_SYSCOMMAND,SC_MINIMIZE,0); break; case IDM_PAUZE: if (game_status != GAME_PLAYING) break; if (game_pauze != TRUE) { WinStopTimer(hab,hwndClient,idTimer); stat = WinCheckMenuItem(hMenu,IDM_PAUZE,TRUE); game_pauze = TRUE; } else { game_pauze = FALSE; // gets a timer idTimer = WinStartTimer(hab,hwndClient,ID_TIMER,30); stat = WinCheckMenuItem(hMenu,IDM_PAUZE,FALSE); WinInvalidateRect(hwnd, NULL, TRUE); } break; case IDM_QUIT: stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE); stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE); stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE); free_all(); game_status = GAME_INTRO; if (game_pauze) { game_pauze = FALSE; //while (!SetTimer(hwnd,ID_TIMER,10,NULL)) //if (IDCANCEL == MessageBox (hwnd, "Cannot get timer handle!", szProgName,MB_ICONEXCLAMATION | MB_RETRYCANCEL)) //exit(0); // add a better shutdown here //CheckMenuItem(hmenu,IDM_PAUZE,MF_UNCHECKED); } game_duration = 200; WinInvalidateRect(hwnd, NULL, TRUE); break; case IDM_PLAY: free_all(); stat = WinEnableMenuItem(hMenu,IDM_PLAY,FALSE); stat = WinEnableMenuItem(hMenu,IDM_QUIT,TRUE); stat = WinEnableMenuItem(hMenu,IDM_PAUZE,TRUE); init_objekts(); game_level = 1; // init powerups to default game_pauze = FALSE; game_maxshots = MAXSHOT; game_shots = 1; game_turning = 10; game_shotlife = 20; game_rearshot = FALSE; game_shieldduration = 0; init_game(); game_status = GAME_PLAYING; game_score = 0; game_duration = 25; game_life = 3; WinInvalidateRect(hwnd, NULL, TRUE); break; default: break; } break; case WM_PAINT: hps = WinBeginPaint(hwnd,NULLHANDLE,&rc); WinQueryWindowRect(hps,&rc); WinFillRect(hps,&rc,CLR_BLACK); sizel.cx = 2000 ; sizel.cy = 2000 ; GpiSetPS (hps, &sizel, PU_PELS) ; GpiQueryPageViewport(hps,&rc); rc.xLeft = 0;//xView / 2 ; rc.xRight = xView ; rc.yBottom = 0;//yView / 2 ; rc.yTop = yView; GpiSetPageViewport (hps, &rc) ; if (game_status == GAME_HISCORE) hiscore(hps); if (game_status == GAME_PLAYING && game_pauze) game(hps); WinEndPaint(hps); break; default: return(WinDefWindowProc(hwnd,messg,mp1,mp2)); } return(MRESULT)0L; }