VOID DisplayDriveInfo (HWND hWnd, ULONG ulInx) { CHAR szVolumeLabel[12]; ULONG ulTotalSpace, ulAllocated, ulAvailable; WinSetDlgItemText (hWnd, IDC_LOCATION, DriveInfo[ulInx].szLocation); WinSetDlgItemText (hWnd, IDC_REMOVABLE, DriveInfo[ulInx].szRemovable); WinSetDlgItemText (hWnd, IDC_FILESYSTEM, DriveInfo[ulInx].szFileSystem); WinSetDlgItemText (hWnd, IDC_DESCRIPTION, szDriveDescription[DriveInfo[ulInx].ulDescriptionIndex]); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,SPTR_WAIT,FALSE)); QueryVolumeLabel (DriveInfo[ulInx].szDrive[0] - 'A' + 1, szVolumeLabel); WinSetDlgItemText (hWnd, IDC_VOLUMELABEL, szVolumeLabel); QueryDiskSpace (DriveInfo[ulInx].szDrive[0] - 'A' + 1, &ulTotalSpace, &ulAllocated, &ulAvailable); FormatNumberField (hWnd, IDC_TOTALSPACE, ulTotalSpace); FormatNumberField (hWnd, IDC_ALLOCATED, ulAllocated); FormatNumberField (hWnd, IDC_AVAILABLE, ulAvailable); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,SPTR_ARROW,FALSE)); return; }
/*------------------------------------------------------------------------*/ BOOL IsOnLineEnd(POINTL mouseptl, pLines pLin,WINDOWINFO *pwi, USHORT *corner ) { POINTL ptl1,ptl2; if (!pLin) return FALSE; ptl1.x = (LONG)(pLin->ptl1.x * pwi->usFormWidth ); ptl1.y = (LONG)(pLin->ptl1.y * pwi->usFormHeight); ptl1.x += (LONG)pwi->fOffx; ptl1.y += (LONG)pwi->fOffy; ptl2.x = (LONG)(pLin->ptl2.x * pwi->usFormWidth ); ptl2.y = (LONG)(pLin->ptl2.y * pwi->usFormHeight); ptl2.x += (LONG)pwi->fOffx; ptl2.y += (LONG)pwi->fOffy; if (mouseptl.x >= ( ptl1.x - 5 ) && mouseptl.x <= ( ptl1.x + 5 ) && mouseptl.y >= ( ptl1.y - 5 ) && mouseptl.y <= ( ptl1.y + 5 )) { *corner = 1; WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENWSE,FALSE)); return TRUE; } else if (mouseptl.x >= ( ptl2.x - 5 ) && mouseptl.x <= ( ptl2.x + 5 ) && mouseptl.y >= ( ptl2.y - 5 ) && mouseptl.y <= ( ptl2.y + 5 )) { *corner = 2; WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENWSE,FALSE)); return TRUE; } return FALSE; }
void OS2Factory::changeCursor( CursorType_t type ) const { LONG id; switch( type ) { default: case kDefaultArrow: id = SPTR_ARROW; break; case kResizeNWSE: id = SPTR_SIZENWSE; break; case kResizeNS: id = SPTR_SIZENS; break; case kResizeWE: id = SPTR_SIZEWE; break; case kResizeNESW: id = SPTR_SIZENESW; break; } HPOINTER hptr = WinQuerySysPointer( HWND_DESKTOP, id, FALSE ); WinSetPointer( HWND_DESKTOP, hptr ); m_cursorType = type; }
static BOOL _setFullscreen(PGROPDATA pGrop, ULONG ulModeIdx) { PVIDEOMODE pMode = &pGrop->stModes.pList[ulModeIdx]; RECTL rectl; LONG lX, lY, lW, lH; // Move _client_ window to up-left corner of screen, set client window size // equals mode size. rectl.xLeft = 0; rectl.yBottom = 0; rectl.xRight = pMode->ulWidth; rectl.yTop = pMode->ulHeight; WinCalcFrameRect( pGrop->hwndFrame, &rectl, FALSE ); lX = rectl.xLeft; lY = pGrop->ulDTHeight - pMode->ulHeight + rectl.yBottom; lW = rectl.xRight - rectl.xLeft; lH = rectl.yTop - rectl.yBottom; pGrop->fInternalResize = TRUE; WinSetWindowPos( pGrop->hwndFrame, HWND_TOP, lX, lY, lW, lH, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE ); pGrop->fInternalResize = FALSE; _captureMouse( pGrop, TRUE ); #ifdef GROP_NO_MOUSE_IN_FULLSCREEN WinSetPointer( pGrop->hwndDT, NULLHANDLE ); #endif WinPostMsg( pGrop->hwnd, WM_VRNENABLED, 0, 0 ); WinSetVisibleRegionNotify( pGrop->hwnd, FALSE ); if ( !pGrop->pVideoSys->fnSetMode( pGrop->pVSData, pMode, TRUE, pGrop->hwndDT, pGrop->hdcDT ) ) return FALSE; return TRUE; }
static MRESULT APIENTRY Char ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 mp2 ) { /*************************************************************************** * Find the instance data. * ***************************************************************************/ PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ; /*************************************************************************** * Get the message data. * ***************************************************************************/ USHORT Flags = (USHORT) SHORT1FROMMP ( mp1 ) ; //UCHAR Repeat = (UCHAR) CHAR3FROMMP ( mp1 ) ; //UCHAR ScanCode = (UCHAR) CHAR4FROMMP ( mp1 ) ; //USHORT Char = (USHORT) SHORT1FROMMP ( mp2 ) ; USHORT VKey = (USHORT) SHORT2FROMMP ( mp2 ) ; /*************************************************************************** * Ignore keys being released, invalid characters, dead keys and * * invalid composite characters. * ***************************************************************************/ if ( ( Flags & KC_KEYUP ) OR ( Flags & KC_INVALIDCHAR ) OR ( Flags & KC_DEADKEY ) OR ( Flags & KC_INVALIDCOMP ) ) { Sys_BeepNote ( ) ; return ( MRFROMSHORT ( FALSE ) ) ; } /*************************************************************************** * Intercept the ESC virtual key to abort margin set mode. * ***************************************************************************/ if ( Flags & KC_VIRTUALKEY ) { switch ( VKey ) { case VK_ESC: { if ( Data->Capture ) { Data->Capture = FALSE ; Sys_ReleaseCapture ( ) ; HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ; WinSetPointer ( HWND_DESKTOP, Ptr ) ; Sys_SetFocus ( Data->HadFocus ) ; WorkSpace PS ( "HRuler::Char", 0, Window, Data->pDevice, int(Data->Metric) ) ; PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ; RECTL Rectangle ; WinQueryWindowRect ( Window, &Rectangle ) ; PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ; POINTL ButtonSize = { 8, 8 } ; PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ; PS.SetMix ( FM_INVERT ) ; PS.SetLineType ( LINETYPE_ALTERNATE ) ; POINTL Point = { Data->Tick, Rectangle.yBottom } ; PS.Move ( Point ) ; Point.y = Rectangle.yTop ; PS.DrawLine ( Point ) ; Data->Mode = NOTMOVING ; } break ; } } } /*************************************************************************** * Return. * ***************************************************************************/ return ( MRFROMSHORT ( TRUE ) ) ; }
static MRESULT APIENTRY Button1Up ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) { /*************************************************************************** * Find the instance data. * ***************************************************************************/ PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ; /*************************************************************************** * If the mouse wasn't captured, return. * ***************************************************************************/ if ( NOT Data->Capture ) return ( MRFROMSHORT ( FALSE ) ) ; /*************************************************************************** * Get the presentation space. * ***************************************************************************/ WorkSpace PS ( "HRuler::Button1Up", 0, Window, Data->pDevice, int(Data->Metric) ) ; PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ; /*************************************************************************** * Find out where the mouse touched. * ***************************************************************************/ RECTL Rectangle ; WinQueryWindowRect ( Window, &Rectangle ) ; POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ; PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ; PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ; POINTL ButtonSize = { 8, 8 } ; PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ; #ifdef DEBUG Log ( "HRuler::Button1Up: Mouse at %i,%i (%i,%i). Rectangle %i,%i-%i,%i. ButtonSize %i.%i (8x8).", Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop, ButtonSize.x, ButtonSize.y ) ; #endif /*************************************************************************** * Erase the previous hairline. * ***************************************************************************/ PS.SetMix ( FM_INVERT ) ; PS.SetLineType ( LINETYPE_ALTERNATE ) ; POINTL Point = { Data->Tick, Rectangle.yBottom } ; PS.Move ( Point ) ; Point.y = Rectangle.yTop ; PS.DrawLine ( Point ) ; /*************************************************************************** * Release the mouse. * ***************************************************************************/ Data->Capture = FALSE ; Sys_ReleaseCapture ( ) ; /*************************************************************************** * Restore the normal mouse pointer. * ***************************************************************************/ HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ; WinSetPointer ( HWND_DESKTOP, Ptr ) ; /*************************************************************************** * Restore the keyboard focus. * ***************************************************************************/ Sys_SetFocus ( Data->HadFocus ) ; /*************************************************************************** * Process final location of mouse. * ***************************************************************************/ switch ( Data->Mode ) { case MOVELEFT: { Data->Tick = TICK(Mouse.x) ; if ( ( Data->Tick < 0 ) OR ( Data->Tick >= Data->RightMargin ) ) { Sys_BeepError ( ) ; break ; } Sys_SendMessage ( OWNER(Window), WM_SET_LEFTMARGIN, MPFROMLONG(Data->Tick), 0 ) ; break ; } case MOVERIGHT: { Data->Tick = TICK(Mouse.x) ; if ( ( Data->Tick <= Data->LeftMargin ) OR ( Data->Tick > Data->PageWidth ) ) { Sys_BeepError ( ) ; break ; } Sys_SendMessage ( OWNER(Window), WM_SET_RIGHTMARGIN, MPFROMLONG(Data->Tick), 0 ) ; break ; } case MOVETAB: { Data->Tick = TICK(Mouse.x) ; if ( ( Mouse.y > Rectangle.yTop ) OR ( Mouse.y < Rectangle.yBottom ) OR ( Data->Tick <= Data->LeftMargin ) OR ( Data->Tick >= Data->RightMargin ) ) { Sys_SendMessage ( OWNER(Window), WM_CLEAR_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), 0 ) ; break ; } Sys_SendMessage ( OWNER(Window), WM_MOVE_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), MPFROMLONG(Data->Tick) ) ; break ; } case SETTAB: { Data->Tick = TICK(Mouse.x) ; if ( ( Mouse.y > Rectangle.yTop ) OR ( Mouse.y < Rectangle.yBottom ) OR ( Data->Tick <= Data->LeftMargin ) OR ( Data->Tick >= Data->RightMargin ) ) { Sys_BeepError ( ) ; break ; } Sys_SendMessage ( OWNER(Window), WM_SET_TAB, MPFROMLONG(Data->Tick), 0 ) ; break ; } } /*************************************************************************** * Reset mode. * ***************************************************************************/ Data->Mode = NOTMOVING ; /*************************************************************************** * We're done. * ***************************************************************************/ return ( MRFROMSHORT ( TRUE ) ) ; }
static VOID _wmGropQuery(PGROPDATA pGrop, PGROPQUERY pQuery) { debug( "pQuery->ulQuery = %u", pQuery->ulQuery ); switch( pQuery->ulQuery ) { case QUERY_SET_MODE: pQuery->fSuccess = _querySetMode( pGrop, pQuery->pUserMode ); break; case QUERY_SET_FS: if ( pGrop->ulModeIdx == ~0 ) // Mode was not set. pQuery->fSuccess = FALSE; else { BOOL fFullscreen; switch( pQuery->ulSetFullscreen ) { case GROP_SET_FS_ON: fFullscreen = TRUE; break; case GROP_SET_FS_SWITCH: fFullscreen = !pGrop->fFullscreen; break; default: // GROP_SET_FS_OFF, _GROP_SET_FS_PANIC_OFF fFullscreen = FALSE; } // Fullscreen mode BPP and desktop mode BPP must be same to switch // from fullscreen to the desktop if video system does not support // conversion for BPP. Exception is _GROP_SET_FS_PANIC_OFF // - we should switch to the desktop at exit if not all GROP objects // was destroyed by user. // Switching from fullscreen to window is always available for: // DIVE - can blit buffer with any BPP, // VMANComptible - manages just one mode. if ( !fFullscreen && ( pQuery->ulSetFullscreen != _GROP_SET_FS_PANIC_OFF ) && ( !pGrop->pVideoSys->fBPPConvSup ) && ( pGrop->stModes.pList[pGrop->stModes.ulDesktopMode].ulBPP != pGrop->stModes.pList[pGrop->ulModeIdx].ulBPP ) ) pQuery->fSuccess = FALSE; else pQuery->fSuccess = ( fFullscreen == pGrop->fFullscreen ) || _setMode( pGrop, pGrop->ulModeIdx, fFullscreen ); } break; case QUERY_SET_POINTER: debug( "QUERY_SET_POINTER: %u", pQuery->hptrPointer ); pGrop->hptrPointer = pQuery->hptrPointer; pQuery->fSuccess = WinSetPointer( pGrop->hwndDT, pGrop->hptrPointer ); debug( "WinSetPointer(): %s", pQuery->fSuccess ? "TRUE" : "FALSE" ); // Unvisible pointer when mouse captured or fullscreen - relative mouse // mode, we shoult move pointer to the center (_captureMouse() do it). if ( ( pGrop->hptrPointer == NULLHANDLE ) && ( pGrop->fFullscreen || pGrop->fCapture ) ) { debug( "Relative mouse mode, call _captureMouse()" ); _captureMouse( pGrop, TRUE ); } break; case QUERY_SET_CAPTURE: if ( pGrop->fCapture != pQuery->fCapture ) { debug( "QUERY_SET_CAPTURE: %s", pQuery->fCapture ? "TRUE" : "FALSE" ); pGrop->fCapture = pQuery->fCapture; if ( !pGrop->fFullscreen ) // Mouse already is captured in fullscreen. _captureMouse( pGrop, pQuery->fCapture ); } pQuery->fSuccess = TRUE; break; case QUERY_MINIMIZE: pQuery->fSuccess = WinSetWindowPos( pGrop->hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_MINIMIZE | SWP_DEACTIVATE ); break; case QUERY_MOUSEMOVE: pQuery->fSuccess = _queryMouseMove( pGrop, pQuery->pointlPos.x, pQuery->pointlPos.y ); break; case QUERY_UPDATE: // Do not update when fullscreen but we are on the desktop now. pQuery->fSuccess = ( pGrop->fFullscreen && !pGrop->fActive ) || ( ( pGrop->ulModeIdx != ~0 ) && pGrop->pVideoSys->fnUpdate( pGrop->pVSData, pGrop, pQuery->GQUPDATE.cRect, pQuery->GQUPDATE.prectl ) ); break; case QUERY_SET_PALETTER: pQuery->fSuccess = pGrop->pVideoSys->fnSetPalette( pGrop->pVSData, pQuery->GQSETPAL.ulFirst, pQuery->GQSETPAL.ulNumber, pQuery->GQSETPAL.pColors ); break; case QUERY_SET_TITLE: pQuery->fSuccess = WinSetWindowText( pGrop->hwndFrame, pQuery->pszText ); break; case QUERY_SET_ICON: pQuery->fSuccess = (BOOL)WinSendMsg( pGrop->hwndFrame, WM_SETICON, MPFROMLONG(pQuery->hptrPointer), 0 ); break; default: debug( "Unknown query %u", pQuery->ulQuery ); pQuery->fSuccess = FALSE; } debug( "Done, result: %s", pQuery->fSuccess ? "TRUE" : "FALSE" ); if ( pQuery->hevReady != NULLHANDLE ) DosPostEventSem( pQuery->hevReady ); }
unsigned int CallDosDebug( dos_debug __far *buff ) { QMSG qmsg; int num_paints; int i; struct { RECTL rcl; HWND hwnd; } paints[MAX_PAINTS]; HPS ps; char class_name[80]; TID tid; if( !IsPMDebugger() ) { return( Call32BitDosDebug( buff ) ); } switch( buff->Cmd ) { case DBG_C_ClearWatch: case DBG_C_Freeze: case DBG_C_LinToSel: case DBG_C_NumToAddr: case DBG_C_ReadCoRegs: case DBG_C_ReadMemBuf: case DBG_C_ReadMem_D: case DBG_C_ReadReg: case DBG_C_SelToLin: case DBG_C_SetWatch: case DBG_C_ThrdStat: case DBG_C_WriteCoRegs: case DBG_C_WriteMemBuf: case DBG_C_WriteMem_D: case DBG_C_WriteReg: return( Call32BitDosDebug( buff ) ); } switch( buff->Cmd ) { case DBG_C_Go: case DBG_C_SStep: case DBG_C_Term: ReleaseQueue( buff->Pid, buff->Tid ); } DebugReqBuff = buff; StopBuff = *buff; DosSemSet( &DebugDoneSem ); DosSemClear( &DebugReqSem ); num_paints = 0; if( IsPMDebugger() ) { while( WinGetMsg( HabDebugger, &qmsg, 0L, 0, 0 ) || InDosDebug ) { WinQueryClassName( qmsg.hwnd, MAX_CLASS_NAME, class_name ); switch( qmsg.msg ) { case WM_CHAR: if( ( SHORT1FROMMP( qmsg.mp1 ) & KC_VIRTUALKEY ) && ( SHORT2FROMMP( qmsg.mp2 ) == VK_BREAK ) ) { SetBrkPending(); DosCreateThread( StopApplication, &tid, stack2 + STACK_SIZE ); DosSetPrty( PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid ); WakeThreads( StopBuff.Pid ); DosSemWait( &StopDoneSem, SEM_INDEFINITE_WAIT ); DosSemSet( &StopDoneSem ); } break; case WM_COMMAND: CantDoIt(); break; default: if( strcmp( class_name, "GUIClass" ) == 0 || strcmp( class_name, "WTool" ) == 0 ) { switch( qmsg.msg ) { case WM_PAINT: if( num_paints >= MAX_PAINTS ) --num_paints; paints[num_paints].hwnd = qmsg.hwnd; ps = WinBeginPaint( qmsg.hwnd, 0, &paints[ num_paints ].rcl ); GpiErase( ps ); WinEndPaint( ps ); num_paints++; break; case WM_BUTTON1DOWN: case WM_BUTTON2DOWN: case WM_BUTTON3DOWN: CantDoIt(); break; case WM_MOUSEMOVE: { HPOINTER hourglass = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); if( WinQueryPointer( HWND_DESKTOP ) != hourglass ) { WinSetPointer( HWND_DESKTOP, hourglass ); } break; } default: WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 ); } } else { WinDispatchMsg( HabDebugger, &qmsg ); } } } } else { DosSemWait( &DebugDoneSem, SEM_INDEFINITE_WAIT ); } switch( buff->Cmd ) { case DBG_N_Exception: case DBG_N_AsyncStop: case DBG_N_Watchpoint: AssumeQueue( buff->Pid, buff->Tid ); break; } for( i = 0; i < num_paints; ++i ) { WinInvalidateRect( paints[i].hwnd, &paints[i].rcl, FALSE ); } return( DebugReqResult ); }
/************************************************************************* * * 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 */
BOOL CALLBACK CDialogDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #endif { int i; class CDialog *dlgClass; CPC_MSGMAP_ENTRY *msgMap = NULL; #if defined(__OS2__) dlgClass = (class CDialog *)WinQueryWindowULong (hwnd, QWL_USER); #elif defined(__NT__) dlgClass = (class CDialog *)GetWindowLong (hwnd, GWL_USERDATA); #endif if (dlgClass != NULL) { dlgClass->m_msg = msg; #if defined(__OS2__) dlgClass->m_mp1 = mp1; dlgClass->m_mp2 = mp2; #elif defined(__NT__) dlgClass->m_wParam = wParam; dlgClass->m_lParam = lParam; #endif msgMap = dlgClass->GetMessageMap (); } switch (msg) { #if defined(__OS2__) case WM_INITDLG: { CDIALOG_DATA *cData = (CDIALOG_DATA *)mp2; #elif defined(__NT__) case WM_INITDIALOG: { CDIALOG_DATA *cData = (CDIALOG_DATA *)lParam; #endif dlgClass = cData->Dlg; dlgClass->m_hWnd = hwnd; dlgClass->lv_Selected = -1; #if defined(__OS2__) WinSetWindowULong (hwnd, QWL_USER, (ULONG)dlgClass); #elif defined(__NT__) SetWindowLong (hwnd, GWL_USERDATA, (LONG)dlgClass); #endif dlgClass->OnInitDialog (); #if defined(__OS2__) break; #elif defined(__NT__) return ((BOOL)TRUE); #endif } #if defined(__OS2__) case WM_CONTROL: for (i = 0; msgMap[i].pfn != NULL; i++) { if (msgMap[i].nMessage == msg) { if (msgMap[i].nID >= SHORT1FROMMP (mp1) && msgMap[i].nLastID <= SHORT1FROMMP (mp1)) { if (msgMap[i].nCode == SHORT2FROMMP (mp1)) { (dlgClass->*msgMap[i].pfn) (); break; } } } } return (0); #endif #if defined(__NT__) case WM_NOTIFY: { LPNMHDR pnmh = (LPNMHDR)lParam; NM_LISTVIEW *pnmv = (NM_LISTVIEW *)lParam; if (pnmh->code == NM_DBLCLK) dlgClass->OnOK (); else if (pnmh->code == LVN_ITEMCHANGED) { if (!(pnmv->uNewState & LVIS_SELECTED) && (pnmv->uOldState & LVIS_SELECTED)) dlgClass->lv_Selected = -1; if (pnmv->uNewState & LVIS_SELECTED) dlgClass->lv_Selected = (SHORT)pnmv->iItem; } else { for (i = 0; msgMap[i].pfn != NULL; i++) { if (msgMap[i].nMessage == msg && msgMap[i].nCode == pnmh->code) { if (msgMap[i].nID >= pnmh->idFrom && msgMap[i].nLastID <= pnmh->idFrom) { (dlgClass->*msgMap[i].pfn) (); break; } } } } return (0); } #endif #if defined(__OS2__) case WM_CHAR: if (SHORT1FROMMP (mp1) & KC_VIRTUALKEY && SHORT2FROMMP (mp2) == VK_F1) dlgClass->OnHelp (); break; #endif case WM_HELP: dlgClass->OnHelp (); break; /* #if defined(__OS2__) case WM_HELP: { USHORT id; HWND hwndHelpInstance; id = WinQueryWindowUShort (hwnd, QWS_ID); hwndHelpInstance = WinQueryHelpInstance (dlgClass->owner_hWnd); WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, MPFROM2SHORT (id, 0), MPFROMSHORT (HM_RESOURCEID)); break; } #endif */ case WM_COMMAND: #if defined(__OS2__) switch (SHORT1FROMMP (mp1)) { #elif defined(__NT__) switch (LOWORD (wParam)) { #endif case IDOK: dlgClass->OnOK (); break; case IDCANCEL: dlgClass->OnCancel (); break; case IDHELP: dlgClass->OnHelp (); break; default: for (i = 0; msgMap[i].pfn != NULL; i++) { #if defined(__OS2__) if (msgMap[i].nMessage == msg) { if (msgMap[i].nID >= SHORT1FROMMP (mp1) && msgMap[i].nLastID <= SHORT1FROMMP (mp1)) { #elif defined(__NT__) if (msgMap[i].nMessage == msg && msgMap[i].nCode == HIWORD (wParam)) { if (msgMap[i].nID >= LOWORD (wParam) && msgMap[i].nLastID <= LOWORD (wParam)) { #endif (dlgClass->*msgMap[i].pfn) (); break; } } } break; } return (0); #if defined(__NT__) case WM_CLOSE: EndDialog (hwnd, FALSE); break; #endif default: if (msgMap != NULL) { for (i = 0; msgMap[i].pfn != NULL; i++) { if (msgMap[i].nMessage == msg) { (dlgClass->*msgMap[i].pfn) (); return (0); } } } break; } #if defined(__OS2__) return (WinDefDlgProc (hwnd, msg, mp1, mp2)); #elif defined(__NT__) return ((BOOL)FALSE); #endif } CDialog::CDialog (PSZ dialogTemplate, HWND p_hWnd) { strcpy (dlgTemplate, dialogTemplate); owner_hWnd = p_hWnd; help_hWnd = NULL; #if defined(__OS2__) WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE)); #elif defined(__NT__) #endif } CDialog::~CDialog () { #if defined(__OS2__) if (help_hWnd != NULL) WinDestroyHelpInstance (help_hWnd); #elif defined(__NT__) #endif } VOID CDialog::Center () { #if defined(__OS2__) RECTL rc; #elif defined(__NT__) RECT rc; #endif #if defined(__OS2__) WinQueryWindowRect (m_hWnd, &rc); rc.yTop = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - (rc.yTop - rc.yBottom)) / 2; rc.xLeft = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - (rc.xRight - rc.xLeft)) / 2; WinSetWindowPos (m_hWnd, NULL, rc.xLeft, rc.yTop, 0, 0, SWP_MOVE); #elif defined(__NT__) GetWindowRect (m_hWnd, &rc); rc.top = (GetSystemMetrics (SM_CYSCREEN) - (rc.bottom - rc.top)) / 2; rc.left = (GetSystemMetrics (SM_CXSCREEN) - (rc.right - rc.left)) / 2; SetWindowPos (m_hWnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE|SWP_NOZORDER); #endif } LONG CDialog::DoModal () { LONG ulResult = 0L; CDIALOG_DATA cDialog; cDialog.cbSize = sizeof (CDIALOG_DATA); cDialog.Dlg = this; #if defined(__OS2__) WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, FALSE)); ulResult = WinDlgBox (HWND_DESKTOP, owner_hWnd, CDialogDlgProc, NULLHANDLE, atoi (dlgTemplate), &cDialog); #elif defined(__NT__) ulResult = DialogBoxParam (hinst, MAKEINTRESOURCE (atoi (dlgTemplate)), owner_hWnd, (DLGPROC)CDialogDlgProc, (LPARAM)&cDialog); #endif return (ulResult); } // ---------------------------------------------------------------------- // Windowing API replacement // ---------------------------------------------------------------------- VOID CDialog::EndDialog (USHORT Result) { #if defined(__OS2__) WinDismissDlg (m_hWnd, Result); #elif defined(__NT__) ::EndDialog (m_hWnd, Result); #endif } VOID CDialog::GetDlgItemText (int id, PSZ text, USHORT size) { #if defined(__OS2__) WinQueryDlgItemText (m_hWnd, id, size, text); #elif defined(__NT__) ::GetDlgItemText (m_hWnd, id, text, size); #endif } VOID CDialog::GetDlgItemText (int id, USHORT size, PSZ text) { #if defined(__OS2__) WinQueryDlgItemText (m_hWnd, id, size, text); #elif defined(__NT__) ::GetDlgItemText (m_hWnd, id, text, size); #endif }
BOOL APIENTRY InstallPager(INSTALL *pstInst) { int iIndex; int iCountPos; int iDestPathEnd; int iSourcePathEnd; APIRET rc; BOOL bSuccess = TRUE; HPOINTER hPointer; // int iLen; int iFileCount; int iObjectCount; int iEnd; HOBJECT hObject; HOBJECT *phObject; BOOL bObjectBad; unsigned int uiAttrib; ULONG ulFileCount; ULONG cbDataSize = sizeof(ULONG); HINI hInstalledProfile; HINI hSourceProfile; hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath); iEnd = sprintf(szFileNumber,"File_"); strcpy(szDestSpec,pstInst->pszAppsPath); iDestPathEnd = strlen(szDestSpec); szDestSpec[iDestPathEnd++] = '\\'; szDestSpec[iDestPathEnd] = 0; hPointer = WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE); WinSetPointer(HWND_DESKTOP,hPointer); strcpy(szSourceSpec,pstInst->pszSourcePath); iSourcePathEnd = strlen(szSourceSpec); szSourceSpec[iSourcePathEnd++] = '\\'; szPagerEXEname[0] = 0; szInstallEXEname[0] = 0; sprintf(szInstalledIniPath,"%s%s",szDestSpec,pstInst->paszStrings[UNINSTALLINIFILENAME]); if (!MakePath(pstInst->hwndFrame,pstInst->pszAppsPath)) return(FALSE); hInstalledProfile = PrfOpenProfile(pstInst->hab,szInstalledIniPath); cbDataSize = sizeof(ULONG); if (!PrfQueryProfileData(hInstalledProfile,"Installed","Files",&iFileCount,&cbDataSize)) iFileCount = 0; if (!PrfQueryProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,&cbDataSize)) iObjectCount = 0; sprintf(szPath,"%c:\\DELLOCKS.CMD",pstInst->chBootDrive); DosForceDelete(szPath); if (pstInst->bCopyCOMi) { strcpy(szDestSpec,pstInst->pszAppsPath); iDestPathEnd = strlen(szDestSpec); szDestSpec[iDestPathEnd++] = '\\'; szDestSpec[iDestPathEnd] = 0; sprintf(pstInst->paszStrings[DRIVERINISPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[DDNAME]); if (strlen(pstInst->paszStrings[CURRENTDRIVERSPEC]) != 0) { if (strcmp(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC]) != 0) { strcpy(szPath,pstInst->paszStrings[DDNAME]); AppendINI(szPath); sprintf(szFileName,"Existing %s",szPath); if (pstInst->paszStrings[REMOVEOLDDRIVERSPEC] != NULL) strcpy(pstInst->paszStrings[REMOVEOLDDRIVERSPEC],pstInst->paszStrings[CURRENTDRIVERSPEC]); AppendINI(pstInst->paszStrings[DRIVERINISPEC]); AppendINI(pstInst->paszStrings[CURRENTDRIVERSPEC]); pstInst->pfnPrintProgress(szFileName,pstInst->paszStrings[DRIVERINISPEC]); if (pstInst->bSavedDriverIniFile) { sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive); DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING); pstInst->bSavedDriverIniFile = FALSE; if (pstInst->fCurrentIni != UNINSTALL_SAVE_INI) DosDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]); } else if (DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING) != NO_ERROR) { sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive); DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING); DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]); } } else { rc = DosQueryPathInfo(pstInst->paszStrings[CURRENTDRIVERSPEC],1,&stFileStatus,sizeof(FILESTATUS3)); if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND)) { sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive); DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING); DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]); } } } else { AppendINI(pstInst->paszStrings[DRIVERINISPEC]); rc = DosQueryPathInfo(pstInst->paszStrings[DRIVERINISPEC],1,&stFileStatus,sizeof(FILESTATUS3)); if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND)) { sprintf(szPath,"%c:\\COMDDINI.OLD",pstInst->chBootDrive); DosCopy(szPath,pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING); DosForceDelete(szPath); } } AppendINI(pstInst->paszStrings[DRIVERINISPEC]); sprintf(&szDestSpec[iDestPathEnd],"%s",pstInst->paszStrings[DDNAME]); sprintf(&szSourceSpec[iSourcePathEnd],"%s",pstInst->paszStrings[DDNAME]); pstInst->pfnPrintProgress(pstInst->paszStrings[DDNAME],szDestSpec); if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR) { bSuccess = FALSE; if (!DisplayCopyError(pstInst->paszStrings[DDNAME],szDestSpec,rc)) goto gtFreePathMem; } ClearReadOnly(szDestSpec); itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); AppendINI(szSourceSpec); if (DosQueryPathInfo(szSourceSpec,FIL_STANDARD,&stFileStatus,sizeof(FILESTATUS3)) == NO_ERROR) { AppendINI(szDestSpec); strcpy(szPath,pstInst->paszStrings[DDNAME]); AppendINI(szPath); pstInst->pfnPrintProgress(szPath,szDestSpec); DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING); ClearReadOnly(szDestSpec); itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); } strcpy(szFileKey,"File_"); iCountPos = strlen(szFileKey); ulFileCount = 0; PrfQueryProfileData(hSourceProfile,"COMi","Files",&ulFileCount,&cbDataSize); for (iIndex = 1;iIndex <= ulFileCount;iIndex++) { itoa(iIndex,&szFileKey[iCountPos],10); if (PrfQueryProfileString(hSourceProfile,"COMi",szFileKey,0,szFileName,18) != 0) { if (iIndex == 1) strcpy(szCOMiINFname,szFileName); strcpy(&szDestSpec[iDestPathEnd],szFileName); strcpy(&szSourceSpec[iSourcePathEnd],szFileName); pstInst->pfnPrintProgress(szFileName,szDestSpec); if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR) { bSuccess = FALSE; if (!DisplayCopyError(szFileName,szDestSpec,rc)) goto gtFreePathMem; } ClearReadOnly(szDestSpec); itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); } } MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE); /* ** This entry must be placed here so the the Configuration DLL can "find" the ** COMi initialization file, before the device driver is actually loaded. */ PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Initialization",pstInst->paszStrings[DRIVERINISPEC]); PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Version",pstInst->paszStrings[COMIVERSION]); } if (pstInst->bCopyPager) { bCopyLibraries = TRUE; szPagerEXEname[0] = 0; strcpy(szDestSpec,pstInst->pszAppsPath); iDestPathEnd = strlen(szDestSpec); szDestSpec[iDestPathEnd++] = '\\'; szDestSpec[iDestPathEnd] = 0; strcpy(szFileKey,"File_"); iCountPos = strlen(szFileKey); ulFileCount = 0; PrfQueryProfileData(hSourceProfile,"Pager","Files",&ulFileCount,&cbDataSize); for (iIndex = 1;iIndex <= ulFileCount;iIndex++) { itoa(iIndex,&szFileKey[iCountPos],10); if (PrfQueryProfileString(hSourceProfile,"Pager",szFileKey,0,szFileName,18) != 0) { if (iIndex == 1) strcpy(szPagerEXEname,szFileName); strcpy(&szDestSpec[iDestPathEnd],szFileName); strcpy(&szSourceSpec[iSourcePathEnd],szFileName); pstInst->pfnPrintProgress(szFileName,szDestSpec); if (!CopyFile(szSourceSpec,szDestSpec)) { bSuccess = FALSE; if (!DisplayCopyError(szFileName,szDestSpec,rc)) goto gtFreePathMem; } itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); } } PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Version",pstInst->paszStrings[APPVERSION]); } if (pstInst->bCopyUtil) { strcpy(szDestSpec,pstInst->pszAppsPath); iDestPathEnd = strlen(szDestSpec); szDestSpec[iDestPathEnd++] = '\\'; szDestSpec[iDestPathEnd] = 0; strcpy(szFileKey,"File_"); iCountPos = strlen(szFileKey); ulFileCount = 0; PrfQueryProfileData(hSourceProfile,"Utilities","Files",&ulFileCount,&cbDataSize); for (iIndex = 1;iIndex <= ulFileCount;iIndex++) { itoa(iIndex,&szFileKey[iCountPos],10); if (PrfQueryProfileString(hSourceProfile,"Utilities",szFileKey,0,szFileName,18) != 0) { strcpy(&szDestSpec[iDestPathEnd],szFileName); strcpy(&szSourceSpec[iSourcePathEnd],szFileName); pstInst->pfnPrintProgress(szFileName,szDestSpec); if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR) { bSuccess = FALSE; if (!DisplayCopyError(szFileName,szDestSpec,rc)) goto gtFreePathMem; } ClearReadOnly(szDestSpec); itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); } } } if (pstInst->bCopyInstall) { bCopyLibraries = TRUE; szInstallEXEname[0] = 0; strcpy(szDestSpec,pstInst->pszAppsPath); iDestPathEnd = strlen(szDestSpec); szDestSpec[iDestPathEnd++] = '\\'; szDestSpec[iDestPathEnd] = 0; sprintf(&szDestSpec[iDestPathEnd],pstInst->paszStrings[INIFILENAME]); strcpy(&szSourceSpec[iSourcePathEnd],pstInst->paszStrings[INIFILENAME]); PrfCloseProfile(hSourceProfile); DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING); ClearReadOnly(szDestSpec); hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath); itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); strcpy(szFileKey,"File_"); iCountPos = strlen(szFileKey); ulFileCount = 0; PrfQueryProfileData(hSourceProfile,"Install","Files",&ulFileCount,&cbDataSize); for (iIndex = 1;iIndex <= ulFileCount;iIndex++) { itoa(iIndex,&szFileKey[iCountPos],10); if (PrfQueryProfileString(hSourceProfile,"Install",szFileKey,0,szFileName,18) != 0) { if (iIndex == 1) strcpy(szInstallEXEname,szFileName); strcpy(&szDestSpec[iDestPathEnd],szFileName); strcpy(&szSourceSpec[iSourcePathEnd],szFileName); pstInst->pfnPrintProgress(szFileName,szDestSpec); if (!CopyFile(szSourceSpec,szDestSpec)) { // bSuccess = FALSE; if (!DisplayCopyError(szFileName,szDestSpec,rc)) goto gtFreePathMem; } itoa(++iFileCount,&szFileNumber[iEnd],10); PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec); } } } PrfWriteProfileString(hInstalledProfile,"Installed","Program Path",pstInst->pszAppsPath); PrfWriteProfileData(hInstalledProfile,"Installed","Files",&iFileCount,sizeof(int)); if (strlen(pstInst->paszStrings[CONFIGDDLIBRARYNAME]) != 0) { sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDLIBRARYNAME]); PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]); } if (strlen(pstInst->paszStrings[CONFIGDDHELPFILENAME]) != 0) { sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDHELPFILENAME]); PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Help",szPath); } if (strlen(pstInst->paszStrings[CONFIGAPPLIBRARYNAME]) != 0) { sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPLIBRARYNAME]); PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]); } if (strlen(pstInst->paszStrings[CONFIGAPPHELPFILENAME]) != 0) { sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPHELPFILENAME]); PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Help",szPath); } pstInst->bFilesCopied = TRUE; MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE); if (pstInst->bCreateObjects) { bObjectBad = FALSE; strcpy(szFileNumber,"Object_"); iEnd = strlen(szFileNumber); hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS); if (hObject == 0) { sprintf(&szFolderName[strlen(szFolderName)],":1"); hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS); } if (hObject != 0) { itoa(++iObjectCount,&szFileNumber[iEnd],10); PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT)); szDestSpec[iDestPathEnd - 1] = 0; sprintf(szPath,"<%s>",szFolderName); strcpy(szFolderName,szPath); if (szCOMiINFname[0] != 0) { sprintf(szSetupString,"%sEXENAME=VIEW.EXE;PARAMETERS=%s\\%s",szINFobjectSetup,szDestSpec,pstInst->paszStrings[CONFIGDDNAME]); sprintf(szObjectName,"%s Users Guide",pstInst->paszStrings[CONFIGDDNAME]); hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS); if (hObject != 0) { itoa(++iObjectCount,&szFileNumber[iEnd],10); PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT)); } else bObjectBad = TRUE; } if (szPagerEXEname[0] != 0) { iEnd = sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s;ASSOCFILTER=*.PAG;PARAMETERS=% /MSG:\"[Message: ]\" /CFG:\"%*\"",szProgramObjectSetup,szDestSpec,szPagerEXEname,szDestSpec); if (strlen(pstInst->paszStrings[APPICONFILE]) != 0) sprintf(&szSetupString[iEnd],";ICON=%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[APPICONFILE]); strcat(szObjectName,"Drop"); hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS); if (hObject != 0) { itoa(++iObjectCount,&szFileNumber[iEnd],10); PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT)); } else bObjectBad = TRUE; } if (szInstallEXEname[0] != 0) { sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s",szProgramObjectSetup,szDestSpec,szInstallEXEname,szDestSpec); hObject = WinCreateObject("WPProgram","OS/tools Install",szSetupString,szFolderID,CO_UPDATEIFEXISTS); if (hObject != 0) { itoa(++iObjectCount,&szFileNumber[iEnd],10); PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT)); } else bObjectBad = TRUE; } PrfWriteProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,sizeof(int)); } } if (bObjectBad || (hObject == 0)) { sprintf(szMessage,"At least one desktop object was not created due to an unknown system error."); sprintf(szCaption,"Object(s) Not Created!"); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szMessage, szCaption, 0, (MB_MOVEABLE | MB_OK)); } gtFreePathMem: PrfCloseProfile(hInstalledProfile); PrfCloseProfile(hSourceProfile); return(bSuccess); }
MRESULT EXPENTRY ClientWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { PGLOBALS pg; RECTL rectl; ULONG rc; LONG lrc; char szWork[ LEN_WORKSTRING ]; FILE *f; SWP swp; switch( msg ) { case WM_CLOSE: // mshell does not close, but at least it can minimize and get out of the way pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinSetWindowPos( pg->hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_MINIMIZE ); return (MRESULT) 0; case WM_CREATE: // see create.c pg = Create( hwnd ); break; case WM_COMMAND: // see menu.c return Command( hwnd, msg, mp1, mp2 ); case WM_CONTROL: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); switch( SHORT1FROMMP( mp1 )) { case ID_LISTBOX: switch( SHORT2FROMMP( mp1 )) { case LN_ENTER: // user wants to start a program WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 ); // see object.c // get index from listbox; works as index to aStartem array lrc = (LONG) WinSendMsg( pg->hwndListbox, LM_QUERYSELECTION, (MPARAM)LIT_FIRST, 0 ); #ifdef DEBUG pmassert( pg->hab, LIT_NONE != lrc ); #endif // pass index of program to start in mp2 WinPostMsg( pg->hwndObject, WM_USER_START, (MPARAM) hwnd, (MPARAM) lrc ); break; } break; } return (MRESULT) 0; case WM_ERASEBACKGROUND: // see Petzold, WM_PAINT below return (MRESULT) 1; case WM_MOUSEMOVE: // display which pointer? if( WinIsWindowEnabled( hwnd )) { // not disabled; display regular pointer WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE )); } else { // disabled; display hourglass WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE )); } return (MRESULT) 0; case WM_NACK_NO_INI: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 ); #define PSZNOINIPROMPT "\ Can't find \\MSHELL.INI, a plain text file used to configure MShell.\n\ \n\ Create a default one?" rc = (ULONG)WinMessageBox( HWND_DESKTOP, pg->hwndFrame, PSZNOINIPROMPT, CAPTION, 0, MB_ICONEXCLAMATION | MB_YESNOCANCEL ); if( MBID_YES == rc ) { #define PSZDEFINI "\ * MSHELL.INI defines programs that MShell can start\n\ * Configure MSHELL.EXE using the RUNWORKPLACE setting in CONFIG.SYS\n\ * MSHELL.EXE finds its INI in the root of the boot drive\n\ * Each line in the INI file has two parts:\n\ * 1: program title text to appear in MShell window\n\ * 2: the CMD.EXE start command to start the program\n\ * Separate the parts with a semicolon\n\ * Lines starting with ! start automatically at bootup\n\ * Comment lines begin with *\n\ \n\ * command processors\n\ OS/2 Command Prompt; start /f\n\ DOS Command Prompt; start /f /fs /dos\n\ Win-OS/2; start /fs /dos /c winos2\n\ \n\ * other stuff\n\ Help for Start; start help start\n\ Solitaire; start /f klondike\n\ \n\ * example to start from other than C:\\\n\ * PM Program; d: & cd \\pmpgm & start pmpgm\n" if( f = fopen( "\\MSHELL.INI", "w" )) { fprintf( f, PSZDEFINI ); fclose( f ); } // make like user pressed refresh WinPostMsg( hwnd, WM_COMMAND, (MPARAM)IDM_REFRESH, 0 ); } return (MRESULT) 0; case WM_NACK_NO_SPOOLER: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinMessageBox( HWND_DESKTOP, pg->hwndFrame, "Sorry, could not start the spooler.", CAPTION, 0, MB_CANCEL ); return (MRESULT) 0; case WM_NACK_SYNTAX_ERROR: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); // line number of INI file in mp2 sprintf( szWork, "Line %d of \\mshell.ini is unrecognized.", (SHORT) mp2 ); WinMessageBox( HWND_DESKTOP, pg->hwndFrame, szWork, CAPTION, 0, MB_CANCEL ); return (MRESULT) 0; case WM_PAINT: // see WM_ERASEBACKGROUND above; // see Petzold sections on control windows which are children of the client window break; case WM_SAVEAPPLICATION: // save restored position pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinQueryWindowPos( pg->hwndFrame, &swp ); if( swp.fl & SWP_MINIMIZE ) { // mshell is currently minimized pg->profile.swpMinimized.x = swp.x; pg->profile.swpMinimized.y = swp.y; // get restored size from window words pg->profile.swp.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE ); pg->profile.swp.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE ); pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE ); pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE ); } else if( swp.fl & SWP_MAXIMIZE ) { // mshell is currently maximized // get restored size from window words pg->profile.swp.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE ); pg->profile.swp.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE ); pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE ); pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE ); // get minimized icon position from window words pg->profile.swpMinimized.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XMINIMIZE ); pg->profile.swpMinimized.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YMINIMIZE ); } else { // mshell is in the restored state pg->profile.swp = swp; // get minimized icon position from window words pg->profile.swpMinimized.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XMINIMIZE ); pg->profile.swpMinimized.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YMINIMIZE ); } // write to ini PrfWriteProfileData( HINI_PROFILE, INI_APP, INIKEY_PROFILE, (PVOID)&pg->profile, sizeof( PROFILE )); #if 0 // save restored position // TO DO: save icon position pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinQueryWindowPos( pg->hwndFrame, &(pg->profile.swp) ); if( 0 == ( pg->profile.swp.fl & ( SWP_MINIMIZE | SWP_MAXIMIZE ))) { // app in restored state, swp struct fine the way it is. }else{ // app currently min'd or max'd. pull restore info from win words pg->profile.swp.x = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE); pg->profile.swp.y = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE); pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE); pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE); } // write to ini PrfWriteProfileData( HINI_PROFILE, INI_APP, INIKEY_PROFILE, (PVOID)&(pg->profile), sizeof( PROFILE )); #endif break; case WM_SIZE: pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinQueryWindowRect( hwnd, &rectl ); WinSetWindowPos( pg->hwndListbox, HWND_TOP, 0, 0, rectl.xRight, rectl.yTop, SWP_SIZE | SWP_MOVE | SWP_SHOW ); return (MRESULT) 0; case WM_USER_ACK: // re-enable the window pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); switch( (ULONG)mp1 ) { case WM_CREATE: WinSetFocus( HWND_DESKTOP, pg->hwndListbox ); break; } WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 ); return (MRESULT) 0; case WM_USER_DISABLE_CLIENT: // this message sent; disable menu action bar as well pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinEnableWindow( pg->hwndClient, FALSE ); WinEnableWindow( pg->hwndMenubar, FALSE ); WinEnableWindow( pg->hwndListbox, FALSE ); return (MRESULT) 0; case WM_USER_ENABLE_CLIENT: // this message sent; enable client and action bar pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); WinEnableWindow( pg->hwndClient, TRUE ); WinEnableWindow( pg->hwndMenubar, TRUE ); WinEnableWindow( pg->hwndListbox, TRUE ); return (MRESULT) 0; } return( WinDefWindowProc( hwnd, msg, mp1, mp2 )); }
MRESULT EXPENTRY ROPsTestWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { CHAR szTitle[300]; /* Title Bar Text */ HPS hPS; /* Presentation Space Handle */ LONG lClrBack; /* Colour Holder */ LONG lClrFore; /* Colour Holder */ LONG lScrollInc;/* Scroll Increment */ PBITMAPARRAYFILEHEADER pbafh; /* Bitmap Array File Header Pointer */ PBITMAPARRAYFILEHEADER2 pbafh2; /* Bitmap Array File Header Pointer */ PBITMAPFILEHEADER pbfh; /* Bitmap File Header Pointer */ PBITMAPFILEHEADER2 pbfh2; /* Bitmap File Header Pointer */ PBITMAPINFO pbmi; /* Bitmap Info Pointer */ PBITMAPINFO2 pbmi2; /* Bitmap Info Pointer */ POINTL ptl; /* Pointer Position */ RECTL rcl; /* Window Rectangle */ register INT i; /* Index */ switch ( msg ) { /************************************************************************/ /* Window being created, perform window initialization */ /************************************************************************/ case WM_CREATE : hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE); hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE); cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); hmenuROPs = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_MENU); hwndHScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_HORZSCROLL); hwndVScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_VERTSCROLL); /************************************************/ /* PDSGetTemplate is used to allow controls in */ /* windows. Do not remove this function if you */ /* intend to include controls within the window.*/ /************************************************/ PDSGetTemplate(hWnd, WIN_ROPSTEST); break; /************************************************************************/ /* Window being sized */ /************************************************************************/ case WM_SIZE : if ( cBitmaps ) SizeBitmapStack(hWnd); WinQueryWindowRect(hWnd, &rcl); if ( (lHorzRange = cxROP - (cxWindow = rcl.xRight - rcl.xLeft)) < 0L ) { lHorzRange = 0L; rclROP.xLeft = 0L; rclROP.xRight = cxROP; } else rclROP.xRight = rclROP.xLeft + cxWindow; if ( (lVertRange = cyROP - (cyWindow = rcl.yTop - rcl.yBottom)) < 0L ) { lVertRange = 0L; rclROP.yBottom = 0L; rclROP.yTop = cyROP; } else rclROP.yBottom = (rclROP.yTop = cyROP - lVertPos) - cyWindow; WinSendMsg(hwndVScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos), MPFROM2SHORT(0, lVertRange)); WinSendMsg(hwndVScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow, cyROP), 0L); WinSendMsg(hwndHScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos), MPFROM2SHORT(0, lHorzRange)); WinSendMsg(hwndHScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow, cxROP), 0L); WinInvalidateRect(hWnd, NULL, FALSE); break; /************************************************************************/ /* Perform menu initialization */ /************************************************************************/ case WM_INITMENU : switch ( SHORT1FROMMP(mp1) ) { case IDM_DISPLAY : WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_BITMAPARRAY, TRUE), MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? MIA_CHECKED : 0)); WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_ROPARRAY, TRUE), MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? 0 : MIA_CHECKED)); break; case IDM_FILE : break; } break; /************************************************************************/ /* Process key press from keyboard */ /************************************************************************/ case WM_CHAR : if ( CHARMSG(&msg)->fs & KC_VIRTUALKEY ) switch ( CHARMSG(&msg)->vkey ) { case VK_PAGEUP : WinSendMsg(hWnd, WM_VSCROLL, MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEUP)); return(0L); case VK_PAGEDOWN : WinSendMsg(hWnd, WM_VSCROLL, MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEDOWN)); return(0L); } /************************************************/ /* PDSKeyProc is used to allow controls in */ /* windows. Do not remove this function if you */ /* intend to include controls within the window.*/ /************************************************/ return(PDSKeyProc(hWnd, msg, mp1, mp2)); /************************************************************************/ /* Button 2 being depressed */ /************************************************************************/ case WM_BUTTON2DOWN : if ( !fBitmapArray && hbmROP ) { lHorzPos = SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L)); lVertPos = SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L)); lRop = (lVertPos + (cyWindow - SHORT2FROMMP(mp1))) / cyImage * 16 + (lHorzPos + SHORT1FROMMP(mp1)) / cxImage; WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)ViewROPDlgProc, (HMODULE)NULL, DLG_VIEWROP, NULL); } break; /************************************************************************/ /* Process vertical scroll requests */ /************************************************************************/ case WM_VSCROLL : lVertPos = SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L)); switch ( HIUSHORT(mp2) ) { case SB_LINEUP : lScrollInc = -cyImage; break; case SB_LINEDOWN : lScrollInc = cyImage; break; case SB_PAGEUP : lScrollInc = -cyWindow; break; case SB_PAGEDOWN : lScrollInc = cyWindow; break; case SB_SLIDERPOSITION : case SB_SLIDERTRACK : lScrollInc = SHORT1FROMMP(mp2) - lVertPos; break; default : return(0L); } if ( lScrollInc = max(-lVertPos, min(lScrollInc, lVertRange - lVertPos)) ) { rclROP.yBottom = (rclROP.yTop = cyROP - (lVertPos += lScrollInc)) - cyWindow; WinInvalidateRect(hWnd, NULL, FALSE); WinSendMsg(hwndVScroll, SBM_SETPOS, MPFROM2SHORT(lVertPos, 0), 0L); } break; /************************************************************************/ /* Process horizontal scroll requests */ /************************************************************************/ case WM_HSCROLL : lHorzPos = SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L)); switch ( HIUSHORT(mp2) ) { case SB_LINELEFT : lScrollInc = -cxImage; break; case SB_LINERIGHT : lScrollInc = cxImage; break; case SB_PAGELEFT : lScrollInc = -cxWindow; break; case SB_PAGERIGHT : lScrollInc = cxWindow; break; case SB_SLIDERPOSITION : case SB_SLIDERTRACK : lScrollInc = SHORT1FROMMP(mp2) - lHorzPos; break; default : return(0L); } if ( lScrollInc = max(-lHorzPos, min(lScrollInc, lHorzRange - lHorzPos)) ) { rclROP.xRight = (rclROP.xLeft = (lHorzPos += lScrollInc)) + cxWindow; WinInvalidateRect(hWnd, NULL, FALSE); WinSendMsg(hwndHScroll, SBM_SETPOS, MPFROM2SHORT(lHorzPos, 0), 0L); } break; /************************************************************************/ /* Process control selections */ /************************************************************************/ case WM_CONTROL : switch ( SHORT2FROMMP(mp1) ) { } break; /************************************************************************/ /* Process menu and button selections */ /************************************************************************/ case WM_COMMAND : switch ( SHORT1FROMMP(mp1) ) { case IDM_OPTIONS : if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OptionsDlgProc, (HMODULE)NULL, DLG_OPTIONS, NULL) ) { WinSetPointer(HWND_DESKTOP, hptrWait); CreateROPBitmap(hWnd); WinInvalidateRect(hWnd, NULL, FALSE); WinSetPointer(HWND_DESKTOP, hptrArrow); } break; case IDM_OPEN : if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OpenBitmapDlgProc, (HMODULE)NULL, DLG_OPENBITMAP, NULL) ) { WinSetPointer(HWND_DESKTOP, hptrWait); hbmView = hbmGetBitmap(szBitmapFile); SizeBitmap(hWnd); if ( cBitmaps ) SizeBitmapStack(hWnd); CreateROPBitmap(hWnd); WinInvalidateRect(hWnd, NULL, FALSE); strcat(memcpy(szTitle, "Bitmap Viewer - ", 17), szBitmapFile); if ( fWindowsBitmap ) strcat(szTitle, " [Windows 3.x format]"); else if ( f20Bitmap ) strcat(szTitle, " [OS/2 2.x format]"); else strcat(szTitle, " [OS/2 1.x format]"); WinSetWindowText(hwndROPsFrame, szTitle); WinSetPointer(HWND_DESKTOP, hptrArrow); } break; case IDM_ROPARRAY : fBitmapArray = FALSE; WinInvalidateRect(hWnd, NULL, FALSE); break; case IDM_BITMAPARRAY : fBitmapArray = TRUE; WinInvalidateRect(hWnd, NULL, FALSE); break; } break; /************************************************************************/ /* Erase window background */ /************************************************************************/ case WM_ERASEBACKGROUND : WinQueryWindowRect(hWnd, &rcl); WinFillRect((HPS)LONGFROMMP(mp1), &rcl, CLR_PALEGRAY); break; /************************************************************************/ /* Paint client window */ /************************************************************************/ case WM_PAINT : GpiCreateLogColorTable(hPS = WinBeginPaint(hWnd, (HPS)NULL, &rcl), 0UL, LCOLF_RGB, 0L, 0L, (PLONG)NULL); /* Display the bitmap array images side-by-side */ if ( fBitmapArray ) { WinFillRect(hPS, &rcl, RGBCLR_PALEGRAY); for ( i = 0; i < cBitmaps; i++ ) { /* Check to see if the image is a 2-colour which */ /* menas that the colours have to be set */ /* explicitely */ if ( abm[i].cColours == 2L ) { lClrBack = lClrFore = 0L; /* Check to see if a 2.x format bitmap since the */ /* the structures are slightly different */ if ( f20Bitmap ) { /* Locate the bitmap information structure */ if ( (cBitmaps == 1) && !fBitmapArray ) { pbfh2 = (PBITMAPFILEHEADER2)abm[i].pb; pbmi2 = (PBITMAPINFO2)&pbfh2->bmp2; } else { pbafh2 = (PBITMAPARRAYFILEHEADER2)abm[i].pb; pbmi2 = (PBITMAPINFO2)&pbafh2->bfh2.bmp2; } /* Transfer the RGB info to the colour */ /* holders */ memcpy(&lClrBack, &pbmi2->argbColor[0], 3); memcpy(&lClrFore, &pbmi2->argbColor[1], 3); } else { /* Locate the bitmap information structure */ if ( (cBitmaps == 1) && !fBitmapArray ) { pbfh = (PBITMAPFILEHEADER)abm[i].pb; pbmi = (PBITMAPINFO)&pbfh->bmp; } else { pbafh = (PBITMAPARRAYFILEHEADER)abm[i].pb; pbmi = (PBITMAPINFO)&pbafh->bfh.bmp; } /* Transfer the RGB info to the colour */ /* holders */ memcpy(&lClrBack, &pbmi->argbColor[0], 3); memcpy(&lClrFore, &pbmi->argbColor[1], 3); } /* Draw the 2-colour bitmap using the */ /* provided colours from the bitmap */ WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL, (PPOINTL)(PVOID)&abm[i].rclDest, lClrFore, lClrBack, DBM_NORMAL); } else /* Draw the bitmap from the array */ WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL, (PPOINTL)(PVOID)&abm[i].rclDest, RGB_WHITE, RGB_BLACK, DBM_NORMAL); /* Draw the 3-D frame around the image */ GpiSetColor(hPS, RGBCLR_SHADOW); GpiMove(hPS, &abm[i].aptlArea[7]); GpiPolyLine(hPS, 2L, &abm[i].aptlArea[4]); GpiSetColor(hPS, RGB_WHITE); GpiPolyLine(hPS, 2L, &abm[i].aptlArea[6]); GpiSetColor(hPS, RGB_BLACK); GpiMove(hPS, &abm[i].aptlArea[3]); GpiPolyLine(hPS, 2L, &abm[i].aptlArea[0]); GpiSetColor(hPS, RGBCLR_PALEGRAY); GpiPolyLine(hPS, 2L, &abm[i].aptlArea[2]); } } else { if ( (rclROP.xRight < cxWindow) || (rclROP.yTop < cyWindow) ) WinFillRect(hPS, &rcl, RGBCLR_PALEGRAY); ptl.x = ptl.y = 0L; WinDrawBitmap(hPS, hbmROP, &rclROP, &ptl, 0L, 0L, DBM_NORMAL); } WinEndPaint(hPS); break; /************************************************************************/ /* Window being destroyed, perform clean-up operations */ /************************************************************************/ case WM_DESTROY : for ( i = 0; i < cBitmaps; i++ ) GpiDeleteBitmap(abm[i].hbm); if ( hbmROP ) GpiDeleteBitmap(hbmROP); if ( pb ) free(pb); break; /* Default message processing */ default : return(WinDefWindowProc(hWnd, msg, mp1, mp2)); } return(0L); }
BOOL WsetWaitPtr(VOID) { HPOINTER hptr = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE); return (hptr? WinSetPointer(HWND_DESKTOP, hptr): FALSE); }
MRESULT PMfrCommands (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) { /* These are the routnes that handle the commands issued by the FRACTINT for PM menus. In most cases, they call another support routine to handle or schedule the event requested by the user. */ SHORT sCommand = SHORT1FROMMP(mp1); switch (sCommand) { case IDM_GO: /* fire up the subtask */ cp.fContinueCalc = TRUE ; if (npNewParms.fNewParms) { CopyParmsToBase(); /* GetMemoryBitmap(); */ SetSwitchEntry (hwnd, szTitleBar, GetFractalName(cp.iFractType) ); } cp.sSubAction = SUB_ACT_CALC; /* we want a Calculation */ DosSemClear (&cp.ulSemTrigger) ; /* release the subthread */ sStatus = STATUS_WORKING ; /* WinInvalidateRect (hwnd, NULL, FALSE) ; */ UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt); EnableMenuItem (hwnd, IDM_GO, FALSE) ; EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ; /* WinStartTimer (hab, hwnd, ID_TIMER, 5000); */ return 0 ; case IDM_PAN: /* Pan selected. Pan to where the cross hairs were */ PanNewCenter(hwnd); fGoodPan = FALSE; return 0; case IDM_ZIN_WIN: /* Zoom to the Window selected. */ EraseZoomBox(hwnd); ZoomNewWindow(hwnd, TRUE); /* zoom in */ fGoodZoom = FALSE; return 0; case IDM_ZOUT_WIN: /* Zoom to the Window selected. */ EraseZoomBox(hwnd); ZoomNewWindow(hwnd, FALSE); /* zoom out */ fGoodZoom = FALSE; return 0; case IDM_FREEZE_HALT: if (sStatus == STATUS_WORKING) { /* schedule the subthread to find a stopping place */ cp.fContinueCalc = FALSE ; EnableMenuItem (hwnd, IDM_FREEZE_HALT, FALSE) ; } if (sStatus == STATUS_READY) { /* we Freeze to play with parms repeatedly */ /* make a copy to play with. We will keep */ /* working with only this copy */ InitNewParms(NULL); /* now change state */ sStatus = STATUS_FROZEN; EnableMenuItem (hwnd, IDM_FREEZE_HALT, FALSE); } return 0 ; case IDM_ABOUT: /* send up the About box */ WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc, (HMODULE) 0, IDD_ABOUT, NULL) ; return 0 ; case IDM_NEW_FRACTAL: /* * send up the Select Fractal Type box. * On OK return, schedule the new parameters. * Handle the special cases needing files or other data * as part of exiting the initial dialog box. */ if (WinDlgBox (HWND_DESKTOP, hwnd, SelFractalDlgProc, (HMODULE) 0, IDD_SET_FRACTTYPE, NULL) ) ScheduleNewParms (hwnd); return 0 ; case IDM_SET_PARAMS: /* * send up the Set Paramters box. * On OK return, schedule the new parameters. */ if (WinDlgBox (HWND_DESKTOP, hwnd, SetParametersDlgProc, (HMODULE) 0, IDD_SET_PARAMS, NULL) ) ScheduleNewParms (hwnd); return 0 ; case IDM_SET_OPTIONS: /* * send up the Set Options box. * On OK return, schedule the new parameters. */ if (WinDlgBox (HWND_DESKTOP, hwnd, SetOptionsDlgProc, (HMODULE) 0, IDD_SET_OPTIONS, NULL) ) ScheduleNewParms (hwnd); return 0 ; case IDM_SET_IMAGE: /* * send up the Set Image box. * On OK return, schedule the new parameters. */ if (WinDlgBox (HWND_DESKTOP, hwnd, SetImageDlgProc, (HMODULE) 0, IDD_SET_IMAGE, NULL) ) ScheduleNewParms (hwnd); return 0 ; case IDM_SET_PALETTE: /* * send up the Set Palette box. * Return is not checked because effects are immediate */ WinDlgBox (HWND_DESKTOP, hwnd, SetPaletteDlgProc, (HMODULE) 0, IDD_SET_PALETTE, NULL) ; return 0 ; case IDM_ZIN_PICK: case IDM_ZOUT_PICK: /* * Send up the Zoom Value dialog box. * On OK return, schedule the new parameters. */ if ( WinDlgBox (HWND_DESKTOP, hwnd, ZoomValueDlgProc, (HMODULE) 0, IDD_NUMBER_PICK, MPFROMP((PVOID) &COMMANDMSG(&msg)->cmd)) ) ScheduleNewParms (hwnd); return 0 ; case IDM_ZIN_2: case IDM_ZIN_5: case IDM_ZIN_10: /* * Zoom in by fixed value. * Schedule the new parameters. */ InitNewParms(NULL); CalcZoomValues(&npNewParms, (double) (sCommand), TRUE ); npNewParms.fNewParms = TRUE; ScheduleNewParms(hwnd); return 0; case IDM_ZOUT_2: case IDM_ZOUT_5: case IDM_ZOUT_10: /* * Zoom out by fixed value. * Schedule the new parameters. */ InitNewParms(NULL); CalcZoomValues(&npNewParms, (double) (sCommand - 10), FALSE ); npNewParms.fNewParms = TRUE; ScheduleNewParms(hwnd); return 0; case IDM_SET_EXTENTS: /* * Send up the Set Extents dialog box. * On OK return, schedule the new parameters. */ if ( WinDlgBox (HWND_DESKTOP, hwnd, SetExtentsDlgProc, (HMODULE) 0, IDD_SET_EXTENTS, NULL) ) ScheduleNewParms (hwnd); return 0; case IDM_SET_SWAP: /* swap Mandel for Julia or vice versa. Handle it as a parm change */ InitNewParms(NULL); if (fractalspecific[npNewParms.iFractType].tojulia != NOFRACTAL && npNewParms.param[0] == 0.0 && npNewParms.param[1] == 0.0) { /* switch to corresponding Julia set */ npNewParms.iFractType = fractalspecific[npNewParms.iFractType].tojulia; npNewParms.param[0] = npNewParms.XCenter; npNewParms.param[1] = npNewParms.YCenter; npNewParms.mxXL = fractalspecific[npNewParms.iFractType].xmin; npNewParms.mxXR = fractalspecific[npNewParms.iFractType].xmax; npNewParms.mxYB = fractalspecific[npNewParms.iFractType].ymin; npNewParms.mxYT = fractalspecific[npNewParms.iFractType].ymax; } else if (fractalspecific[npNewParms.iFractType].tomandel != NOFRACTAL) { /* switch to corresponding Mandel set */ npNewParms.iFractType = fractalspecific[npNewParms.iFractType].tomandel; npNewParms.param[0] = 0.0; npNewParms.param[1] = 0.0; npNewParms.mxXL = fractalspecific[npNewParms.iFractType].xmin; npNewParms.mxXR = fractalspecific[npNewParms.iFractType].xmax; npNewParms.mxYB = fractalspecific[npNewParms.iFractType].ymin; npNewParms.mxYT = fractalspecific[npNewParms.iFractType].ymax; } npNewParms.fNewParms = TRUE; ScheduleNewParms (hwnd); return 0; case IDM_SET_RESET: /* copy the work copy of the parms back from the set used by the calculation engine. This resets any dicking around done with the dialogs. Note: this is only active during FREEZE mode. */ CopyParmsToNew(); return 0; case IDM_HELP_INTRO: /* basic Introductory Help */ SimpleHelp(hab, hwnd, szTitleBar, (HMODULE) 0, IDT_TEXT, IDT_HELP_INTRO); return 0; case IDM_HELP_FRACTTYPE: /* Fractal list Help */ SimpleHelp(hab, hwnd, szTitleBar, (HMODULE) 0, IDT_TEXT, IDT_HELP_TYPES); return 0; case IDM_HELP_OPERATE: /* Menu Help */ SimpleHelp(hab, hwnd, szTitleBar, (HMODULE) 0, IDT_TEXT, IDT_HELP_OPERATE); return 0; case IDM_PRINT_FILE: /* Send up the Print Where Dialog. On OK return, fire up the subtask */ if ( WinDlgBox(HWND_DESKTOP, hwnd, PrintOptionsDlgProc, (HMODULE) 0, IDD_PRINT, NULL) ) { /* fire up the subtask */ cp.sSubAction = SUB_ACT_PRINT; /* we want a Print */ cp.fContinueCalc = TRUE; DosSemClear (&cp.ulSemTrigger) ; /* release the subthread */ sStatus = STATUS_WORKING ; UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt); EnableMenuItem (hwnd, IDM_GO, FALSE) ; EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ; cp.fSuppressPaint = TRUE; WinInvalidateRect(hwnd, NULL, FALSE); } return 0 ; case IDM_READ_FILE: /* Send up the Load/Save Format Dialog to find out the format we will read. Then send up the generic Open File dialog. On OK return, fire up the subtask */ { DLF dlf; HFILE hfDummy; PSZ pszExt; if ( WinDlgBox(HWND_DESKTOP, hwnd, LoadSaveFmtDlgProc, (HMODULE) 0, IDD_LOADSAVE_TYPE, szLoadWhatFmt) ) { FileFmtExt (&pszExt); SetupDLF (&dlf, DLG_OPENDLG, &hfDummy, pszExt, szTitleBar, szOpenTitle, szOpenHelp); if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) ) { /* close the dummy file handle */ DosClose(hfDummy); /* fire up the subtask */ cp.sSubAction = SUB_ACT_LOAD; /* we want a Load */ cp.sSubFunction = cp.sLastLoadSaveType; _fstrcpy(cp.szFileName, dlf.szOpenFile); cp.fContinueCalc = TRUE; DosSemClear (&cp.ulSemTrigger) ; /* release the subthread */ sStatus = STATUS_WORKING ; UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt); EnableMenuItem (hwnd, IDM_GO, FALSE) ; EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ; cp.fSuppressPaint = TRUE; WinInvalidateRect(hwnd, NULL, FALSE); } } return 0 ; } case IDM_SAVE_FILE: /* Send up the Load/Save Format Dialog to find out the format we will be writing. Then send up the generic Save File dialog. On OK return, fire up the subtask */ { DLF dlf; HFILE hfDummy; PSZ pszExt; if ( WinDlgBox(HWND_DESKTOP, hwnd, LoadSaveFmtDlgProc, (HMODULE) 0, IDD_LOADSAVE_TYPE, szSaveWhatFmt) ) { FileFmtExt (&pszExt); SetupDLF (&dlf, DLG_SAVEDLG, &hfDummy, pszExt, szTitleBar, szOpenTitle, szOpenHelp); _fstrcpy(dlf.szOpenFile, cp.szFileName); if (TDF_NOSAVE != DlgFile(hwnd, &dlf) ) { /* close the dummy file handle */ DosClose(hfDummy); /* and delete the dummy file */ DosDelete(dlf.szOpenFile, 0); /* fire up the subtask */ cp.sSubAction = SUB_ACT_SAVE; /* we want a Save */ cp.sSubFunction = cp.sLastLoadSaveType; _fstrcpy(cp.szFileName, dlf.szOpenFile); cp.fContinueCalc = TRUE; DosSemClear (&cp.ulSemTrigger) ; /* release the subthread */ sStatus = STATUS_WORKING ; UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt); EnableMenuItem (hwnd, IDM_GO, FALSE) ; EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ; cp.fSuppressPaint = TRUE; WinInvalidateRect(hwnd, NULL, FALSE); } } return 0 ; } case IDM_READ_COLORMAP: /* Send up the generic Open File dialog. On OK return, read in the file via subroutine. */ { DLF dlf; HFILE hfDummy; SetupDLF (&dlf, DLG_OPENDLG, &hfDummy, "\\*.map", szTitleBar, szColorMapTitle, szColorMapHelp); if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) ) { /* close the dummy file handle */ DosClose(hfDummy); /* throw up the hour-glass */ WinSetCapture(HWND_DESKTOP, hwnd); WinSetPointer(HWND_DESKTOP, hptrWait); /* read it in */ LoadColorMap(dlf.szOpenFile); /* now clean up */ WinSetPointer(HWND_DESKTOP, hptrArrow); WinSetCapture(HWND_DESKTOP, (HWND) NULL); } } return 0; case IDM_WRITE_COLORMAP: /* Send up the generic Save File dialog. On OK return, write the file via subroutine */ { DLF dlf; HFILE hfDummy; SetupDLF (&dlf, DLG_SAVEDLG, &hfDummy, "\\*.map", szTitleBar, szColorMapTitle, szColorMapHelp); if (TDF_NOSAVE != DlgFile(hwnd, &dlf) ) { /* close the dummy file handle */ DosClose(hfDummy); /* throw up the hour-glass */ WinSetCapture(HWND_DESKTOP, hwnd); WinSetPointer(HWND_DESKTOP, hptrWait); /* write it out */ SaveColorMap(dlf.szOpenFile); /* now clean up */ WinSetPointer(HWND_DESKTOP, hptrArrow); WinSetCapture(HWND_DESKTOP, (HWND) NULL); } } return 0; case IDM_CLEAR_CLPB: /* clear the current contents of the clipboard */ WinOpenClipbrd (hab); WinEmptyClipbrd (hab); WinCloseClipbrd (hab); return 0; case IDM_PASTE: { /* paste from the clipboard into us */ USHORT usClipBrdInfo; if ( WinQueryClipbrdFmtInfo(hab, CF_BITMAP, &usClipBrdInfo) ) { /* we have a bitmap to fetch */ /* draw the curtain over the display */ cp.fSuppressPaint = TRUE; WinInvalidateRect(hwnd, NULL, FALSE); WinUpdateWindow(hwnd); /* throw up the hour-glass */ WinSetCapture(HWND_DESKTOP, hwnd); WinSetPointer(HWND_DESKTOP, hptrWait); /* fetch the bitmap */ PMfrFetchClipbrdBmp(hab); /* now clean up */ WinSetPointer(HWND_DESKTOP, hptrArrow); WinSetCapture(HWND_DESKTOP, (HWND) NULL); /* and schedule redrawing the window */ SetSwitchEntry (hwnd, szTitleBar, GetFractalName(cp.iFractType) ); cp.fSuppressPaint = FALSE; WinInvalidateRect(hwnd, NULL, FALSE); } } return 0; case IDM_COPY_BMP: { /* copy to the clipboard from us */ /* throw up the hour-glass */ WinSetCapture(HWND_DESKTOP, hwnd); WinSetPointer(HWND_DESKTOP, hptrWait); /* write the bitmap */ PMfrWriteClipbrdBmp(hab); /* now clean up */ WinSetPointer(HWND_DESKTOP, hptrArrow); WinSetCapture(HWND_DESKTOP, (HWND) NULL); } return 0; } return 0; }
/* * DrawAreaWinProc - window procedure for the drawing area window * - this window is an MDI window */ MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static WPI_POINT start_pt = { -1, -1 }; static WPI_POINT end_pt = { -1, -1 }; static WPI_POINT prev_pt = { -1, -1 }; static WPI_POINT new_pt = { -1, -1 }; static WPI_POINT pt1; static BOOL flbuttondown = FALSE; static BOOL frbuttondown = FALSE; static BOOL fdraw_shape = FALSE; static BOOL firsttime; static BOOL wasicon; int mousebutton; WPI_POINT pointsize; WPI_POINT pt2; #ifndef __OS2_PM__ CREATESTRUCT *cs; MDICREATESTRUCT *mdi_cs; MINMAXINFO *minmax; #endif img_node *node; int i; switch ( msg ) { case WM_CREATE: #ifndef __OS2_PM__ cs = (CREATESTRUCT __FAR *)lparam; mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams; node = (img_node *)mdi_cs->lParam; for( i = 0; i < node->num_of_images; i++ ) { node[i].hwnd = hwnd; } AddImageNode( node ); CreateUndoStack( node ); setTheCursor( -1, hwnd ); wasicon = FALSE; #endif firsttime = TRUE; i = i; return( 0 ); case WM_MDIACTIVATE: if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) { if( _wpi_isiconic( hwnd ) ) { wasicon = TRUE; break; } else { wasicon = FALSE; FocusOnImage( hwnd ); } } return( 0 ); #ifndef __OS2_PM__ case WM_GETMINMAXINFO: node = SelectImage( hwnd ); if( node != NULL ) { minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = node->width + 2 * _wpi_getsystemmetrics( SM_CXFRAME ); minmax->ptMinTrackSize.y = node->height + 2 * _wpi_getsystemmetrics( SM_CYFRAME ) + _wpi_getsystemmetrics( SM_CYCAPTION ) - 1; } break; #endif case UM_SHOWVIEWWINDOW: ShowViewWindows( hwnd ); return 0; case WM_SIZE: if ( _imgwpi_issizerestored( wparam ) ) { ResizeChild( lparam, hwnd, firsttime ); firsttime = FALSE; if( wasicon ) { FocusOnImage( hwnd ); wasicon = FALSE; } #ifndef __OS2_PM__ } else if ( _imgwpi_issizeminimized( wparam ) ) { node = SelectImage( hwnd ); HideViewWindow( hwnd ); DeleteActiveImage(); ClearImageText(); SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L ); wasicon = TRUE; #endif } return( 0 ); #ifndef __OS2_PM__ case WM_CHAR: pointsize = GetPointSize( hwnd ); if( LOWORD( wparam ) == ESC_CHAR ) { if( !(lparam & 0x40000000) ) { switch( toolType ) { case IMGED_PASTE: fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; DontPaste( hwnd, &pt1, pointsize ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( !flbuttondown && !frbuttondown ) { break; } fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); SetRectExists( FALSE ); } else { OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } break; default: break; } } } return( 0 ); #endif case WM_MOUSEMOVE: pointsize = GetPointSize( hwnd ); #ifdef __OS2_PM__ WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] ); #endif IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ OutlineSnap(); #endif break; case IMGED_PASTE: pt1.x = new_pt.x / pointsize.x; pt1.y = new_pt.y / pointsize.y; pt2.x = prev_pt.x / pointsize.x; pt2.y = prev_pt.y / pointsize.y; if( pt1.x != pt2.x || pt1.y != pt2.y ) { DragClipBitmap( hwnd, &pt1, pointsize ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON ); } else if( frbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( flbuttondown || frbuttondown ) { if( new_pt.x / pointsize.x != end_pt.x / pointsize.x || new_pt.y / pointsize.y != end_pt.y / pointsize.y ) { if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else { OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } end_pt = new_pt; SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize ); } } else { SetPosInStatus( &new_pt, &pointsize, hwnd ); } break; case IMGED_FILL: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; default: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; } prev_pt = new_pt; return( 0 ); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: pointsize = GetPointSize( hwnd ); SetCapture( hwnd ); if( msg == WM_LBUTTONDOWN ) { if( frbuttondown ) { break; } #ifdef __OS2_PM__ node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } #endif flbuttondown = TRUE; mousebutton = LMOUSEBUTTON; } else { if( flbuttondown ) { break; } node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } frbuttondown = TRUE; mousebutton = RMOUSEBUTTON; } fdraw_shape = TRUE; IMGED_MAKEPOINT( wparam, lparam, start_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ TransferImage( hwnd ); #endif fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: BeginFreeHand( hwnd ); DrawSinglePoint( hwnd, &start_pt, mousebutton ); break; case IMGED_LINE: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_CLIP: IMGED_MAKEPOINT( wparam, lparam, end_pt ); RedrawPrevClip( hwnd ); OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_FILL: FillArea( &start_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_HOTSPOT: SetIsSaved( hwnd, FALSE ); prev_pt.x = start_pt.x / pointsize.x; prev_pt.y = start_pt.y / pointsize.y; SetNewHotSpot( &prev_pt ); break; default: break; } prev_pt = new_pt; return 0; case WM_LBUTTONUP: case WM_RBUTTONUP: pointsize = GetPointSize( hwnd ); IMGED_MAKEPOINT( wparam, lparam, end_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); if( msg == WM_LBUTTONUP ) { mousebutton = LMOUSEBUTTON; } else { mousebutton = RMOUSEBUTTON; } if( fdraw_shape ) { switch( toolType ) { case IMGED_PASTE: PasteImage( &start_pt, pointsize, hwnd ); flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown || frbuttondown ) { EndFreeHand( hwnd ); RecordImage( hwnd ); } break; case IMGED_LINE: DrawLine( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_CLIP: SetClipRect( hwnd, &start_pt, &end_pt, pointsize ); break; default: break; } fdraw_shape = FALSE; } ReleaseCapture(); flbuttondown = FALSE; frbuttondown = FALSE; prev_pt = new_pt; return( 0 ); case WM_PAINT: RepaintDrawArea( hwnd ); return( 0 ); case WM_QUERYENDSESSION: case WM_CLOSE: if( lastChanceSave( hwnd ) ) { CloseCurrentImage( hwnd ); return( (MRESULT)1 ); } else { return( (MRESULT)0 ); } #ifndef __OS2_PM__ case WM_DESTROY: SetCursor( LoadCursor( NULL, IDC_ARROW ) ); return( 0 ); #endif default: break; } return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) ); } /* DrawAreaWinProc */
static VOID _wmMouseMove(PGROPDATA pGrop, SHORT lX, SHORT lY) { POINTL pointl; if ( ( pGrop->hptrPointer == NULLHANDLE ) && ( pGrop->fCapture /*|| pGrop->fFullscreen*/ ) ) { // Unvisible pointer when mouse captured /*or fullscreen*/ - relative mouse // mode. Send relative mouse coordinates (offset) to the application. // Mouse pointer is unvisible. WinSetPointer( pGrop->hwndDT, NULLHANDLE ); // Internal information about pointer in relative coordinates mode. pGrop->fMouseInViewArea = TRUE; pGrop->ulMouseX = pGrop->stUserMode.ulWidth / 2; pGrop->ulMouseY = pGrop->stUserMode.ulHeight / 2; // Center of the window in window coordinates. pointl.x = ( pGrop->rectlWinArea.xRight - pGrop->rectlWinArea.xLeft ) / 2; pointl.y = ( pGrop->rectlWinArea.yTop - pGrop->rectlWinArea.yBottom ) / 2; // Call user's function with relative coordinates. if ( pGrop->stCallback.fnMouseMove != NULL ) pGrop->stCallback.fnMouseMove( pGrop, TRUE, lX - pointl.x, lY - pointl.y ); // Keep mouse at center of the window. // Center of the window in screen coordinates. pointl.x = ( pGrop->rectlWinArea.xRight + pGrop->rectlWinArea.xLeft ) / 2; pointl.y = ( pGrop->rectlWinArea.yTop + pGrop->rectlWinArea.yBottom ) / 2; // Do not handle mouse move message when we moves to center of the window. pGrop->lSkipMouseMove++; if ( !WinSetPointerPos( pGrop->hwndDT, pointl.x, pointl.y ) ) debug( "WinSetPointerPos() failed" ); return; } if ( pGrop->fFullscreen || ( pGrop->fCapture && pGrop->fActive ) ) { // Restrict the movement of the mouse view area. SHORT lXva = lX, lYva = lY; if ( lX < pGrop->rectlViewArea.xLeft ) lX = pGrop->rectlViewArea.xLeft; else if ( lX >= pGrop->rectlViewArea.xRight ) lX = pGrop->rectlViewArea.xRight - 1; if ( lY < pGrop->rectlViewArea.yBottom ) lY = pGrop->rectlViewArea.yBottom; else if ( lY >= pGrop->rectlViewArea.yTop ) lY = pGrop->rectlViewArea.yTop - 1; if ( lX != lXva || lY != lYva ) { pointl.x = lX; pointl.y = lY; WinMapWindowPoints( pGrop->hwnd, pGrop->hwndDT, &pointl, 1 ); pGrop->lSkipMouseMove++; WinSetPointerPos( pGrop->hwndDT, pointl.x, pointl.y ); } } // Set application pointer when mouse on the view area or system pointer // when it on "unused" space of window (around view area in our window). pointl.x = lX; pointl.y = lY; WinSetPointer( pGrop->hwndDT, WinPtInRect( pGrop->hab, &pGrop->rectlViewArea, &pointl ) ? pGrop->hptrPointer : WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ) ); pGrop->fMouseInViewArea = lX >= pGrop->rectlViewArea.xLeft && lX < pGrop->rectlViewArea.xRight && lY >= pGrop->rectlViewArea.yBottom && lY < pGrop->rectlViewArea.yTop; if ( pGrop->fMouseInViewArea ) { ULONG ulVAWidth = pGrop->rectlViewArea.xRight - pGrop->rectlViewArea.xLeft; ULONG ulVAHeight = pGrop->rectlViewArea.yTop - pGrop->rectlViewArea.yBottom; // Set coordinates relative to the bottom-left corner of the view area. lX -= pGrop->rectlViewArea.xLeft; lY -= pGrop->rectlViewArea.yBottom; // Scale coordinates to the user work area. lX = pGrop->stUserMode.ulWidth * lX / ulVAWidth; lY = pGrop->stUserMode.ulHeight * lY / ulVAHeight; if ( ( pGrop->ulMouseX != lX ) || ( pGrop->ulMouseY != lY ) ) { // Coordinates hava been changed. pGrop->ulMouseX = lX; pGrop->ulMouseY = lY; // Call user's function. if ( pGrop->stCallback.fnMouseMove != NULL ) pGrop->stCallback.fnMouseMove( pGrop, FALSE, lX, lY ); } } }
/*----------------------------------------------------------------------*/ MRESULT EXPENTRY DMLBSubclassListboxProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) /*----------------------------------------------------------------------*/ /* This window procedure is used to subclass a standard PM listbox */ /* control. This procedure will intercept certain mouse events on the */ /* listbox to implement direct-manipulation functions. */ /*----------------------------------------------------------------------*/ { SHORT Item; /* Listbox item number */ DMLBData *InstData; /* This instance-specific data (per listbox) */ /* The lisbox window pointer is to our instance data. */ InstData = WinQueryWindowPtr(hwnd, QWL_USER); switch (msg) { /* Since this is just a subclass setup after the listbox window */ /* is created, we never get a WM_CREATE message here. */ case WM_DESTROY: /* The listbox window is being destroyed. Cleanup any */ /* resources we have allocated in this subclass. */ if (InstData->DragMIcon != NULLHANDLE) { WinDestroyPointer(InstData->DragMIcon); WinDestroyPointer(InstData->DragCIcon); WinDestroyPointer(InstData->NorthIcon); WinDestroyPointer(InstData->SouthIcon); WinDestroyPointer(InstData->DragNoDrp); WinDestroyPointer(InstData->DeletIcon); InstData->DragMIcon = NULLHANDLE; } /* Cleanup other resources */ if (InstData->Dragging) { WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID); } /* Release instance data */ free(InstData); WinSetWindowPtr(hwnd, 0L, NULL); break; case WM_TIMER: /* We get timer messages during dragging to implement */ /* auto-scrolling of listbox when pointer is placed */ /* north or south of the listbox while dragging. */ if (!InstData->Dragging) /* Ignore if not dragging */ break; if (SHORT1FROMMP(mp1)==DRAG_TIMERID) { switch (InstData->PrevLocation) { // Last known location of the pointer case POINT_INSIDE: case POINT_OUTSIDE: /* Do nothing */ break; case POINT_NORTH: /* Scroll up one item */ Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX, 0L, 0L); if ((Item != LIT_NONE) && (Item != 0)) WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item-1), 0L); break; case POINT_SOUTH: /* Scroll down one item */ Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX, 0L, 0L); if (Item != LIT_NONE) WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item+1), 0L); break; } /* switch on PrevLocation */ return 0; } break; case WM_CONTEXTMENU: { SHORT CursorIndx, Max; /* User requested context menu... notify our owner. */ /* First find out what item the pointer is over. */ Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L ); CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER); if ((Max == 0) || (CursorIndx+1 > Max)) CursorIndx = LIT_NONE; /* Tell our owner about it */ return WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_CONTEXT), MPFROMSHORT(CursorIndx)); } case WM_MOUSEMOVE: /* Monitor the position of the mouse relative to the listbox */ /* so we can set the pointer icon correctly and note the */ /* position for use during WM_TIMER processing. */ if (!InstData->Dragging) /* Ignore if not dragging */ break; DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); /* Set pointer icon appropriate for location */ if (InstData->DragMIcon == NULLHANDLE) { // Load all the pointers (one time only) InstData->DragMIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGMOVE); InstData->DragCIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGCOPY); InstData->DragNoDrp= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGNONE); InstData->NorthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGNORTH); InstData->SouthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGSOUTH); InstData->DeletIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGDEL); } switch (InstData->PrevLocation) { case POINT_INSIDE: switch (InstData->TargetDropMode) { case DROPMODE_MOVE: WinSetPointer(HWND_DESKTOP, InstData->DragMIcon); // Use MOVE pointer break; case DROPMODE_COPY: WinSetPointer(HWND_DESKTOP, InstData->DragCIcon); // Use COPY pointer break; case DROPMODE_DELETE: WinSetPointer(HWND_DESKTOP, InstData->DeletIcon); // Use DELETE pointer break; } break; case POINT_OUTSIDE: WinSetPointer(HWND_DESKTOP, InstData->DragNoDrp); // No-drop pointer break; case POINT_NORTH: WinSetPointer(HWND_DESKTOP, InstData->NorthIcon); // Scroll-up pointer break; case POINT_SOUTH: WinSetPointer(HWND_DESKTOP, InstData->SouthIcon); // Scroll-down poineter break; } return (MRESULT)TRUE; /* Note we processed the message */ case WM_BEGINDRAG: { SHORT Max; SHORT i, CursorIndx, hit; /* User started dragging with the pointer on our window */ Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L ); /* If we are currently dragging, cancel it (should not happen) */ if ( InstData->Dragging ) { InstData->Dragging = FALSE; WinSetCapture( HWND_DESKTOP, NULLHANDLE ); return (MRESULT)FALSE; } /* Get index of item under the mouse pointer and check */ /* for reasonable numeric bounds. */ CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER); if ((Max == 0) || (CursorIndx+1 > Max)) { DosBeep( 440L, 50L ); // Don't allow drag if not on a listbox item return (MRESULT)FALSE; } /* Since we currently support dragging only a single item, */ /* de-select all items and just select the one under the */ /* pointer. To support multiple-drag we would probably */ /* need to notify the owner so they could set the selection*/ /* status of all items to be dragged (which may or may not */ /* include the item under the pointer). */ WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPVOID); WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(CursorIndx), MPFROMSHORT(TRUE)); /* Note we are now dragging and capture the pointer. */ InstData->Dragging = TRUE; WinSetCapture( HWND_DESKTOP, hwnd ); InstData->PrevLocation = POINT_INSIDE; WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID, WinQuerySysValue(HWND_DESKTOP, SV_SCROLLRATE)); return (MRESULT)TRUE; break; } case WM_ENDDRAG: { SHORT DropIndx, CurrIndx; SHORT SourceMax, TargetMax; /* Num of items in source/target listbox */ char *CopyText; /* Text to be copied/moved */ USHORT CopyTextLen; /* Length of text */ void *CopyHand; /* Handle of item to be copied/moved */ BOOL SameList = FALSE; /* Source and target are same listbox */ if (!InstData->Dragging) /* Ignore if we are not dragging */ return (MRESULT)FALSE; /* Clear dragging indicators and release pointer */ InstData->Dragging = FALSE; WinSetCapture( HWND_DESKTOP, NULLHANDLE ); WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID); /* See if what is under the pointer will accept the drop */ DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); if (InstData->PrevLocation != POINT_INSIDE) return (MRESULT)TRUE; /* Ignore drop outside a good listbox */ if (hwnd == InstData->TargetHwnd) // Source and target are same listbox SameList = TRUE; SourceMax = (SHORT)WinSendMsg(hwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1; TargetMax = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1; /* Get drop point and original selected point */ DropIndx = DMLBLocateListboxItem(InstData->TargetHwnd, hwnd, SHORT2FROMMP(mp1), LLI_INSERTPOINT); CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L); /* Prevent move onto same item as source, in same listbox */ /* being careful of DropIndx > SourceMax when drop after last item. */ if ((InstData->TargetDropMode==DROPMODE_MOVE) && (SameList) && ((min(DropIndx,SourceMax) == CurrIndx) || (DropIndx == CurrIndx+1))) { DosBeep( 700L, 50L ); /* Don't drop before or after original */ return (MRESULT)TRUE; } /* Make a copy of original to insert */ CopyTextLen = (SHORT)WinSendMsg(hwnd,LM_QUERYITEMTEXTLENGTH,MPFROMSHORT(CurrIndx), 0L) + 1; CopyText = malloc(CopyTextLen); WinSendMsg(hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(CurrIndx, CopyTextLen), MPFROMP(CopyText)); CopyHand = WinSendMsg(hwnd, LM_QUERYITEMHANDLE, MPFROMSHORT(CurrIndx), 0L); /* Insert before insertion point, or at end of list */ if (DropIndx > TargetMax) DropIndx = LIT_END; /* Disable update during insert/delete for smoother visual and */ /* prevent ownerdraw from occuring before new handles are set. */ WinEnableWindowUpdate(hwnd, FALSE); WinEnableWindowUpdate(InstData->TargetHwnd, FALSE); /* Insert into target list */ if (InstData->TargetDropMode != DROPMODE_DELETE) { DropIndx = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_INSERTITEM, MPFROMSHORT(DropIndx), MPFROMP(CopyText)); WinSendMsg(InstData->TargetHwnd, LM_SETITEMHANDLE, MPFROMSHORT(DropIndx), MPFROMP(CopyHand)); } free(CopyText); /* Tell owner of originating listbox what we are doing. We must notify */ /* the owner before we delete items because they may keep dynamic data */ /* in the item handles that has to be freed. The item in question is */ /* the currently selected item in the listbox. */ switch (InstData->TargetDropMode) { case DROPMODE_MOVE: if (!SameList) WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE_MOVE), MPFROMHWND(InstData->TargetHwnd)); break; case DROPMODE_DELETE: WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE), MPFROMHWND(InstData->TargetHwnd)); break; } /* If this is a move, delete original. If it is in the same */ /* listbox as target, get new index since it may have */ /* changed due to inserted copy. */ if ((InstData->TargetDropMode == DROPMODE_MOVE) || (InstData->TargetDropMode == DROPMODE_DELETE)) { CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L); WinSendMsg(hwnd, LM_DELETEITEM, MPFROMSHORT(CurrIndx), 0L); } /* Select the newly inserted item. If the old copy was */ /* above it in the same list, then the item number has changed by 1 */ if ((DropIndx > CurrIndx) && (SameList) && (InstData->TargetDropMode==DROPMODE_MOVE)) DropIndx--; if (InstData->TargetDropMode != DROPMODE_DELETE) { WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE)); WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(DropIndx), MPFROMSHORT(TRUE)); } WinEnableWindowUpdate(hwnd, TRUE); WinEnableWindowUpdate(InstData->TargetHwnd, TRUE); /* Notify target of inserted items if necessary */ switch (InstData->TargetDropMode) { case DROPMODE_MOVE: if (SameList) WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_REORDERED), MPFROMHWND(hwnd)); else WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_MOVE), MPFROMHWND(hwnd)); break; case DROPMODE_COPY: WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_COPY), MPFROMHWND(hwnd)); break; } return (MRESULT)TRUE; } } /* Call previous window procedure to process this message */ return ( (*(InstData->OldProcAddr)) ( hwnd, msg, mp1, mp2 ) ); }
// Message определяет пришедшее сообщение. VOID Clipper_ClipperMessageProcessing( PQMSG Message ) { // Устанавливаем приоритет потока. if( Message->msg == SM_PRIORITY ) { // Устанавливаем приоритет. LONG Class = (LONG) Message->mp1; LONG Delta = (LONG) Message->mp2; DosSetPriority( PRTYS_THREAD, Class, Delta, 0 ); // Запоминаем приоритет. Enhancer.Modules.Clipper->Priority = MAKELONG( Class, Delta ); } // Включаем выделение в текстовом окне. if( Message->msg == SM_BEGIN_VIO_MARKING || Message->msg == SM_END_VIO_MARKING ) { // Узнаем окно рамки. HWND Frame_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return; // Включаем и выключаем выделение. if( Message->msg == SM_BEGIN_VIO_MARKING ) Clipper_BeginVIOMarking( Frame_window ); if( Message->msg == SM_END_VIO_MARKING ) Clipper_EndVIOMarkingAndCopyText( Frame_window ); } // Запоминаем выделенный текст. if( Message->msg == SM_COPY_VIO_TEXT ) { // Если в текстовых окнах не надо запоминать текст - возврат. if( !Clipper.Settings.Mouse_in_VIO ) return; // Узнаем окно рамки. HWND Frame_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return; // Если выделение текста еще не начато - начинаем его. if( !Clipper_VIOMarkingIsInProcess( Frame_window ) ) Clipper_BeginVIOMarking( Frame_window ); // Иначе - завершаем выделение и запоминаем текст. else Clipper_EndVIOMarkingAndCopyText( Frame_window ); } // Вставляем текст в окно. if( Message->msg == SM_PASTE_VIO_TEXT ) { // Если в текстовых окнах не надо запоминать текст - возврат. if( !Clipper.Settings.Mouse_in_VIO ) return; // Узнаем окно рамки. HWND Frame_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return; // Если в окне не идет выделение текста - вставляем текст. if( !Clipper_VIOMarkingIsInProcess( Frame_window ) ) Clipper_PasteTextToVIOWindow( Frame_window ); } // Запоминаем текст при нажатии средней кнопки мыши. if( Message->msg == SM_MB_CLICK ) { // Узнаем окно, с которым работает пользователь. HWND Input_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Input_window ), Input_window ) ) return; // Узнаем окно рабочего стола. HWND Desktop = QueryDesktopWindow(); // Узнаем время, достаточное для двойного нажатия на кнопку мыши. LONG DblClk_delta = WinQuerySysValue( Desktop, SV_DBLCLKTIME ); // Выполняем задержку, чтобы избежать двойного нажатия. while( 1 ) { // Если время последнего нажатия на среднюю кнопку мыши неизвестно - произошло двойное нажатие, возврат. // В это время в очереди потока уже лежит следующее сообщение - SM_MB_DOUBLECLICK. if( WMMBDownTime() == 0 ) { // Освобождаем указатель мыши. ResetPointer(); // Возврат. return; } // Узнаем текущее время. LONG Current_time = WinGetCurrentTime( Enhancer.Application ); // Если прошло достаточно много времени - все в порядке. if( Current_time > WMMBDownTime() ) if( Current_time - WMMBDownTime() > DblClk_delta ) break; // Если время прошло через ноль - возврат. if( Current_time < WMMBDownTime() ) { // Освобождаем указатель мыши. ResetPointer(); // Возврат. return; } // Через некоторое время - устанавливаем указатель мыши "прозрачная стрелка". if( Current_time - WMMBDownTime() > ( DblClk_delta / 2 ) ) if( Resources.Pointer_for_CopyPaste != NULLHANDLE ) WinSetPointer( QueryDesktopWindow(), Resources.Pointer_for_CopyPaste ); // Выполняем задержку. Retard(); } // Освобождаем указатель мыши. ResetPointer(); // Время последнего нажатия на среднюю кнопку мыши - неизвестно. DiscardWMMBDownTime(); // Узнаем ускоритель для этого окна. LONG Accelerator = (LONG) Message->mp2; // Запоминаем текст в окне. ClipboardMouseAction( Input_window, MOUSE_CLIPBOARD_COPY, Accelerator ); } // Вставляем текст в окно при нажатии средней кнопки мыши. if( Message->msg == SM_MB_DOUBLECLICK ) { // Узнаем окно, с которым работает пользователь. HWND Input_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Input_window ), Input_window ) ) return; // Если кнопка мыши снова была нажата - возврат. if( WMMBDownTime() ) return; // Узнаем ускоритель для этого окна. LONG Accelerator = (LONG) Message->mp2; // Вставляем текст в окно. ClipboardMouseAction( Input_window, MOUSE_CLIPBOARD_PASTE, Accelerator ); } // Вставляем текст в окно Mozilla при нажатии FireFox-клавиши. if( Message->msg >= SM_FFX_PASTE_FIRST && Message->msg <= SM_FFX_PASTE_LAST ) { // Узнаем окно, с которым работает пользователь. HWND Input_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Input_window ), Input_window ) ) return; // Вставляем текст в окно. Clipper_PasteFireFoxCharacters( Input_window, Message->msg ); } // Восстанавливаем содержимое Clipboard. if( Message->msg == SM_RESTORE_CLIPBOARD ) Clipper_RestoreClipboard(); // Возврат. return; }
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) ; }
// ------------------------------------------------------------------------------------------------------------ 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 EXPENTRY MimeDlgProc(HWND hwndDlg,ULONG msg,MPARAM mp1,MPARAM mp2) { HPOINTER hptrOrig, hptrWait; static int num_entries; static int entry; static FILE *in; static Container *list; static MimeSet *mimes; UserData *ud; char buffer[1024]; int i; switch(msg) { case WM_INITDLG: hptrWait = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); hptrOrig = WinQueryPointer( HWND_DESKTOP ); WinSetPointer( HWND_DESKTOP, hptrWait ); WinSendMsg(WinWindowFromID(hwndDlg,MIME_NAME),EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXT), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXE), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); mimes = (MimeSet*)mp2; list = new Container(); list->initialise(hwndDlg,MIME_CONT); num_entries = mimes->getSetNum(); for (i=0; i<num_entries; i++) { sprintf(buffer,"%s: %s",mimes->getName(i),mimes->getExtensions(i)); // message("%d/%d %s is %s",i,num_entries,mimes->getName(i),mimes->getExtensions(i)); list->insert(buffer,(UserData*)NULL,8888L,8888L); } WinFocusChange(HWND_DESKTOP,WinWindowFromID(hwndDlg,MIME_CONT),0); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(mimes->getSetNum()-1)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(mimes->getSetNum()-1)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(mimes->getSetNum()-1)); list->setItemFocus(list->getLastInsert()); WinSetPointer( HWND_DESKTOP, hptrOrig ); entry = -1; break; case WM_HELP: showHelpWindow(HELP_MIMES); break; case WM_CLOSE: mimes->reload(); delete list; return WinDefDlgProc(hwndDlg,msg,mp1,mp2); case WM_USER: list->arrange(); break; case WM_CONTROL: switch(SHORT2FROMMP(mp1)) { case CN_HELP: WinSendMsg(hwndDlg,WM_HELP,0,0); break; // sent every time emphasis of an object is changed, so if // change from A to B, get deselect on A, and select on B case CN_EMPHASIS: { PNOTIFYRECORDEMPHASIS nre = (PNOTIFYRECORDEMPHASIS)mp2; ud = (UserData*)nre->pRecord; if (ud != NULL) { char *buffer = new char[4096]; strcpy(buffer,ud->getName()); char *ptr = buffer+strlen(buffer)-1; while (ptr>buffer && *ptr!='.') ptr--; if (*ptr == '.') { int index = mimes->find(ptr); if (index > -1) { entry = index; WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(index)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(index)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(index)); } } delete[] buffer; } } break; case EN_CHANGE: { if (SHORT1FROMMP(mp1) == MIME_EXE) { ud = list->findSelectedRecord(NULL); static int lastindex = 0; if (ud && entry != -1) { if (lastindex == entry) { char *buffer = new char[4096]; WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer); mimes->setCommand(entry,buffer); delete[] buffer; } lastindex = entry; } } } break; } break; case WM_COMMAND: switch( SHORT1FROMMP( mp1 ) ) { case IDM_DELETE: // message("delete"); break; case DID_OK: // all OK, close dialog, return if (entry != -1) { WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer); mimes->setCommand(entry,buffer); } mimes->save(); delete list; WinDismissDlg( hwndDlg, TRUE); return (MRESULT) TRUE; case DID_CANCEL: mimes->reload(); delete list; WinDismissDlg( hwndDlg, TRUE); return (MRESULT) FALSE; } break; default: return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } return (MRESULT) TRUE; }
MRESULT Window::stdWndProc( HWND hWnd, ULONG iMessage, MPARAM mParam1, MPARAM mParam2, BOOL *returned ) { switch( iMessage ) { // case WM_FOCUSCHANGE : case WM_SETSELECTION : case WM_ACTIVATE : { if( type != Window::LISTBOX && type != Window::COMBOLISTBOX ) { focus( (BOOL)mParam1 );//SHORT1FROMMP( mParam2 ) ); } break; } case WM_SETFOCUS : { if( type != Window::LISTBOX && type != Window::COMBOLISTBOX ) focusSet( (BOOL)mParam2 ); break; } case WM_BUTTON1DOWN : { if( type == SCROLLBAR ) setFocus(); HWND hwnd = WinQueryFocus( HWND_DESKTOP ); if( mouseListener.getSize() != 0 ) { mouseButtonDown = TRUE; WinSetCapture( HWND_DESKTOP, hWnd ); WinStartTimer( Application::hab, hWndClient, 1, 50 ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOWN ); } if( hwnd != WinQueryFocus( HWND_DESKTOP ) ) return (MRESULT)TRUE; break; } case WM_BUTTON1UP : { if( type == LISTBOX || type == COMBOLISTBOX ) { performFocusEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); } else if( mouseListener.getSize() != 0 ) { mouseButtonDown = FALSE; WinStopTimer( Application::hab, hWndClient, 1 ); WinSetCapture( HWND_DESKTOP, NULLHANDLE ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::RELEASE ); // return (MPARAM)TRUE; } break; } case WM_BUTTON2DOWN : { if( mouseListener.getSize() != 0 ) { WinSetCapture( HWND_DESKTOP, hWnd ); WinStartTimer( Application::hab, hWndClient, 1, 50 ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOWN ); } break; } case WM_BUTTON2UP : { if( mouseListener.getSize() != 0 ) { WinStopTimer( Application::hab, hWndClient, 1 ); WinSetCapture( HWND_DESKTOP, NULLHANDLE ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::RELEASE ); } break; } case WM_BUTTON1CLICK : { if( mouseListener.getSize() != 0 ) { // Check if triple click int newTick = WinGetCurrentTime( Application::hab ); if( newTick - lastTick <= WinQuerySysValue( HWND_DESKTOP, SV_DBLCLKTIME ) ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::TRIPLECLICK ); } else { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::CLICK ); } } break; } case WM_BUTTON2CLICK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::CLICK ); } break; } case WM_BUTTON1DBLCLK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOUBLECLICK ); } lastTick = WinGetCurrentTime( Application::hab ); break; } case WM_BUTTON2DBLCLK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOUBLECLICK ); } break; } case WM_MOUSEMOVE : { if( currentPointer != NULLHANDLE ) WinSetPointer( HWND_DESKTOP, currentPointer ); if( mouseListener.getSize() != 0 ) { Point pos( (SHORT)SHORT1FROMMP(mParam1), (SHORT)SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, 0, AMouseEvent::MOVE ); } if( currentPointer != NULLHANDLE ) return (MPARAM)TRUE; break; } case WM_TIMER : { if( mouseButtonDown ) { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); WinMapWindowPoints( HWND_DESKTOP, hWnd, &ptl, 1 ); if( ptl.y < 0 || ptl.y > height ) { Point pos( ptl.x, ptl.y ); performMouseEvent( &pos, 0, AMouseEvent::MOVE ); } } break; } case WM_SIZE : { int oldWidth = width, oldHeight = height; SWP swp; WinQueryWindowPos( hWndFrame, &swp ); width = swp.cx; height = swp.cy; size( oldWidth, oldHeight ); break; } case WM_HSCROLL : { int pos = SHORT1FROMMP( mParam2 ), id = SHORT1FROMMP( mParam1 ); switch( SHORT2FROMMP( mParam2 ) ) { case SB_PAGERIGHT : { performScrollbarEvent( id, Scrollbar::PAGERIGHT, pos ); break; } case SB_PAGELEFT : { performScrollbarEvent( id, Scrollbar::PAGELEFT, pos ); break; } case SB_LINERIGHT : { performScrollbarEvent( id, Scrollbar::LINERIGHT, pos ); break; } case SB_LINELEFT : { performScrollbarEvent( id, Scrollbar::LINELEFT, pos ); break; } case SB_SLIDERTRACK : { performScrollbarEvent( id, Scrollbar::HORZTRACK, pos ); break; } case SB_SLIDERPOSITION : { performScrollbarEvent( id, Scrollbar::HORZRELEASED, pos ); break; } } break; } case WM_SYSCOMMAND : { // Check if the parent is a dialog, then chain the WM_SYSCOMMAND if( parent->getType() == DIALOG ) WinSendMsg( ((Window *)parent)->getHWND(), WM_SYSCOMMAND, mParam1, mParam2 ); break; } case WM_VSCROLL : { int id = SHORT1FROMMP( mParam1 ); Scrollbar *scrollbar = (Scrollbar *)getControl( id ); int pos; if( scrollbar ) pos = scrollbar->convertScrollPosToReal( SHORT1FROMMP( mParam2 ) ); else pos = SHORT1FROMMP( mParam2 ); switch( SHORT2FROMMP( mParam2 ) ) { case SB_PAGEDOWN : { performScrollbarEvent( id, Scrollbar::PAGEDOWN, pos ); break; } case SB_PAGEUP : { performScrollbarEvent( id, Scrollbar::PAGEUP, pos ); break; } case SB_LINEDOWN : { performScrollbarEvent( id, Scrollbar::LINEDOWN, pos ); break; } case SB_LINEUP : { performScrollbarEvent( id, Scrollbar::LINEUP, pos ); break; } case SB_SLIDERTRACK : { performScrollbarEvent( id, Scrollbar::VERTTRACK, pos ); break; } case SB_SLIDERPOSITION : { performScrollbarEvent( id, Scrollbar::VERTRELEASED, pos ); break; } } break; } case WM_MOVE : { SWP swp; WinQueryWindowPos( hWndFrame, &swp ); x = swp.x; y = swp.y; move(); break; } case WM_CLOSE : { if( close() ) break; else return (MPARAM)FALSE; } case WM_COMMAND : { if( SHORT1FROMMP( mParam2 ) == CMDSRC_PUSHBUTTON ) { Window *control = (Window *)getControl( SHORT1FROMMP(mParam1)); if( control != NULL ) { if( control->type == PUSHBUTTON ) { control->performButtonEvent( control, control->id ); return FALSE; } } else return FALSE; // In case ESC would close the dialog } break; } case WM_CHAR : { if( type == LISTBOX ) { performFocusEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); } if( (SHORT1FROMMP( mParam1 ) & KC_KEYUP) || (SHORT1FROMMP( mParam1 ) & KC_DEADKEY) || (SHORT1FROMMP( mParam1 ) & KC_INVALIDCOMP) ) break; /* if( SHORT1FROMMP( mParam1 ) & KC_COMPOSITE ) mParam1 = MPFROM2SHORT( SHORT1FROMMP( mParam1 ) & ~KC_VIRTUALKEY, SHORT2FROMMP( mParam1 ) );*/ int modifiers = 0; if( SHORT1FROMMP( mParam1 ) & KC_SHIFT ) modifiers |= KeyDef::SHIFT; if( SHORT1FROMMP( mParam1 ) & KC_ALT ) modifiers |= KeyDef::kALT; if( SHORT1FROMMP( mParam1 ) & KC_CTRL) modifiers |= KeyDef::CTRL; if( SHORT1FROMMP( mParam1 ) & KC_VIRTUALKEY ) { int key = 0, vKey = SHORT2FROMMP( mParam2 ); // Maybe NumLock is on if( SHORT1FROMMP(mParam1) & KC_CHAR && !(vKey == VK_ENTER || vKey == VK_NEWLINE || vKey == VK_TAB || vKey == VK_BACKSPACE )) key = SHORT1FROMMP( mParam2 ); else if( vKey == VK_UP ) key = KeyDef::UP; else if( vKey == VK_DOWN ) key = KeyDef::DOWN; else if( vKey == VK_LEFT ) key = KeyDef::LEFT; else if( vKey == VK_RIGHT ) key = KeyDef::RIGHT; else if( vKey == VK_PAGEUP ) key = KeyDef::PAGEUP; else if( vKey == VK_PAGEDOWN ) key = KeyDef::PAGEDOWN; else if( vKey == VK_INSERT ) key = KeyDef::INSERT; else if( vKey == VK_DELETE ) key = KeyDef::kDELETE; else if( vKey == VK_HOME ) key = KeyDef::HOME; else if( vKey == VK_END ) key = KeyDef::END; else if( vKey == VK_ESC ) key = KeyDef::ESCAPE; else if( vKey == VK_F1 ) key = KeyDef::F1; else if( vKey == VK_F2 ) key = KeyDef::F2; else if( vKey == VK_F3 ) key = KeyDef::F3; else if( vKey == VK_F4 ) key = KeyDef::F4; else if( vKey == VK_F5 ) key = KeyDef::F5; else if( vKey == VK_F6 ) key = KeyDef::F6; else if( vKey == VK_F7 ) key = KeyDef::F7; else if( vKey == VK_F8 ) key = KeyDef::F8; else if( vKey == VK_F9 ) key = KeyDef::F9; else if( vKey == VK_F10 ) key = KeyDef::F10; else if( vKey == VK_F11 ) key = KeyDef::F11; else if( vKey == VK_F12 ) key = KeyDef::F12; else if( vKey == VK_ENTER ) key = KeyDef::ENTER; else if( vKey == VK_NEWLINE ) key = KeyDef::RETURN; else if( vKey == VK_BACKSPACE ) key = KeyDef::BACKSPACE; else if( vKey == VK_TAB ) key = KeyDef::TAB; else if( vKey == VK_BACKTAB ) { key = KeyDef::TAB; modifiers |= KeyDef::SHIFT; } else if( vKey == VK_SPACE ) key = KeyDef::SPACE; if( parent->getType() == DIALOG ) ((Dialog *)parent)->focusHotkey( key ); if( key != 0 ) if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE); // Do not pass up and down key to dialog if this is a combobox (would // move focus) /* if( getFilterDialogArrows() && (vKey == VK_UP || vKey == VK_DOWN) ) return (MPARAM)TRUE;*/ } else { int key = SHORT1FROMMP( mParam2 ); if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE); } break; } case WM_CONTROL : { Window *control = (Window *)getControl( SHORT1FROMMP(mParam1)); if( control != NULL ) { if( control->type == Window::LISTBOX || control->type == Window::COMBOLISTBOX ) { switch( SHORT2FROMMP(mParam1) ) { case LN_KILLFOCUS : control->focus( FALSE ); break; case LN_SETFOCUS : control->focus( TRUE );break; case LN_ENTER : control->performSelectionEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); break; } } else if( control->type == Window::SCROLLBAR ) { switch( SHORT2FROMMP(mParam1) ) { case SLN_KILLFOCUS : control->focus( FALSE ); break; case SLN_SETFOCUS : control->setFocus(); break; } } else if( control->type == Window::RADIOBUTTON || control->type == Window::CHECKBOX ) { switch( SHORT2FROMMP( mParam1) ) { case BN_CLICKED : case BN_DBLCLICKED : control->performButtonEvent( control, control->id ); break; } } } break; } case DM_DRAGOVER: { PDRAGINFO pDInfo; PDRAGITEM pDItem; if( !acceptDropFiles ) return MRFROM2SHORT(DOR_NODROPOP, 0); pDInfo = (PDRAGINFO)mParam1; DrgAccessDraginfo(pDInfo); pDItem = DrgQueryDragitemPtr(pDInfo, 0); USHORT usOp = 0, usDrop = DOR_NEVERDROP; /* Inspect each item to see if it is acceptable */ ULONG ulItems = DrgQueryDragitemCount (pDInfo); for (INT i = 0; i < ulItems; i++) { pDItem = DrgQueryDragitemPtr(pDInfo, i); /* The item is acceptable only if it is copyable and the */ /* operation is a copy, or it is moveable and the operation */ /* is a move, and it can render <DRM_OS2FILE, NULL> */ if (pDItem->fsSupportedOps & DO_COPYABLE) { usOp = DO_COPY; /* Only check files, all types */ if (DrgVerifyRMF(pDItem, "DRM_OS2FILE", 0)) usDrop = DOR_DROP; else { usDrop = DOR_NEVERDROP; break; } } else { /* Must be a file but not droppable in type op */ usDrop = DOR_NODROPOP; usOp = 0; break; } } /* end for all items dragged */ DrgFreeDraginfo(pDInfo); return MRFROM2SHORT(usDrop, usOp); } case DM_DROP: { PDRAGINFO pDInfo; PDRAGITEM pDItem; pDInfo = (PDRAGINFO)mParam1; DrgAccessDraginfo(pDInfo); pDItem = DrgQueryDragitemPtr(pDInfo, 0); ULONG ulItems = DrgQueryDragitemCount (pDInfo); ULONG p; char **files; files = (char **)malloc( sizeof( char * ) * ulItems ); for (INT i=0; i < ulItems; i++) { CHAR DragSrcPath[CCHMAXPATH], DragSrcName[CCHMAXPATH]; pDItem = DrgQueryDragitemPtr(pDInfo, i); DrgQueryStrName(pDItem->hstrContainerName, sizeof(DragSrcPath), (PSZ)DragSrcPath); if (!(PSZ)DragSrcPath) break; if (DragSrcPath[(strlen(DragSrcPath)-1)] != '\\') strcat((PSZ)DragSrcPath, "\\"); /* Use the dragitem source name, it's the real name */ DrgQueryStrName(pDItem->hstrSourceName, sizeof(DragSrcName), (PSZ)DragSrcName); if (!((PSZ)DragSrcName)) break; strcat((PSZ)DragSrcPath, (PSZ)DragSrcName); FILESTATUS3 fsFile; DosError(FERR_DISABLEHARDERR); APIRET rc = DosQueryPathInfo(DragSrcPath, FIL_STANDARD, &fsFile, sizeof(FILESTATUS3)); DosError(FERR_ENABLEHARDERR); if (!rc && !(fsFile.attrFile & FILE_DIRECTORY)) { files[i] = (char *)malloc( strlen(DragSrcPath) + 1 ); strcpy( files[i], DragSrcPath ); DrgSendTransferMsg(pDItem->hwndItem, DM_ENDCONVERSATION, MPFROMLONG(pDItem->ulItemID), MPFROMLONG(DMFL_TARGETSUCCESSFUL)); } else { DosBeep(100,10); // EditorDisplay[BufNum]->DisplayMessage( pszDropNoFile ); } } filesDropped( files, ulItems ); for( i = 0; i < ulItems; i++ ) free( (void *)files[i] ); free( (void *)files ); DrgFreeDraginfo(pDInfo); break; } case WM_USER + 1 : { return (MPARAM)execFromMainThread( (int)mParam1, (void *)mParam2 ); } case WM_USER + 2 : { setFocus(); break; } } *returned = FALSE; return (MRESULT)NULL; }
VOID QueryDrives (HWND hWnd) { PFSQBUFFER2 pfsq2; ULONG ulLen, ulInx, ulAction, ulParmLen, ulDataLen; APIRET RetCode; HFILE hFile; BIOSPARAMETERBLOCK bpb; CHAR szDrive[3] = " :"; BYTE cBlock = 0; WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,SPTR_WAIT,FALSE)); /* Allocate buffer */ DosAllocMem ((PPVOID)&pfsq2, 1024L, fALLOC); DosError (FERR_DISABLEHARDERR); ulNumDrives = 0L; for (ulInx = 0; ulInx < 26; ulInx++) { szDrive[0] = (CHAR)('A' + ulInx); ulLen = 1024L; RetCode = DosQueryFSAttach (szDrive, 0L, FSAIL_QUERYNAME, pfsq2, &ulLen); DriveInfo[ulNumDrives].szDrive[0] = szDrive[0]; DriveInfo[ulNumDrives].szDrive[1] = '\0'; if (RetCode == ERROR_NOT_READY) { /* Assume local, removable, and FAT file system */ strcpy (DriveInfo[ulNumDrives].szLocation, "Local"); strcpy (DriveInfo[ulNumDrives].szRemovable, "Yes"); strcpy (DriveInfo[ulNumDrives].szFileSystem, "FAT"); DriveInfo[ulNumDrives].ulDescriptionIndex = 10L; ulNumDrives++; } else if (RetCode != ERROR_INVALID_DRIVE) { bpb.fsDeviceAttr = 0; /* Attempt to open the device */ if (!DosOpen (szDrive, &hFile, &ulAction, 0L, FILE_NORMAL, FILE_OPEN, OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE, 0L)) { ulParmLen = sizeof(BYTE); ulDataLen = sizeof(BIOSPARAMETERBLOCK); DosDevIOCtl (hFile, IOCTL_DISK, DSK_GETDEVICEPARAMS, (PVOID)&cBlock, ulParmLen, &ulParmLen, (PVOID)&bpb, ulDataLen, &ulDataLen); DosClose (hFile); } else { /* Remote drives may not allow themselves to be opened with the OPEN_FLAGS_DASD access flag. Default to not removable and description of unknown. */ bpb.fsDeviceAttr = 0x0001; bpb.bDeviceType = 7; } /* Is the drive remote? */ if (pfsq2->iType == FSAT_REMOTEDRV) strcpy (DriveInfo[ulNumDrives].szLocation, "Remote"); else strcpy (DriveInfo[ulNumDrives].szLocation, "Local"); /* Is the drive removable? */ if (bpb.fsDeviceAttr & 0x0001) strcpy (DriveInfo[ulNumDrives].szRemovable, "No"); else strcpy (DriveInfo[ulNumDrives].szRemovable, "Yes"); /* Set the description index */ if (bpb.bDeviceType < 10) DriveInfo[ulNumDrives].ulDescriptionIndex = (LONG)bpb.bDeviceType; else DriveInfo[ulNumDrives].ulDescriptionIndex = 7L; /* Set the file system name */ strncpy (DriveInfo[ulNumDrives].szFileSystem, (PSZ)(pfsq2->szName + 1 + pfsq2->cbName), 15); ulNumDrives++; } } DosError (FERR_ENABLEHARDERR); DosFreeMem (pfsq2); /* Add items to the drive listbox */ for (ulInx = 0; ulInx < ulNumDrives; ulInx++) WinSendDlgItemMsg (hWnd, IDC_DRIVELIST, LM_INSERTITEM, (MPARAM)LIT_END, DriveInfo[ulInx].szDrive); WinSendDlgItemMsg (hWnd, IDC_DRIVELIST, LM_SELECTITEM, 0L, (MPARAM)TRUE); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,SPTR_ARROW,FALSE)); return; }
MRESULT EXPENTRY DriverWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { CHAR szFile[CCHMAXPATH]; /* File HOlder */ FILEFINDBUF3 findbuf; /* File Find Buffer */ FONTMETRICS fm; /* Font Metrics Structure */ HDIR hDir = (HDIR)HDIR_CREATE; /* Directory Handle */ HPS hPS; /* Presentation Space Handle */ HWND hwndListBox; /* List Box Window Handle */ LISTBOXCDATA lbwcd; /* List Box Window Control Data */ POWNERITEM poi; /* Owner Item */ RECTL rcl; /* Client Window Rectangle */ ULONG ulFileCnt = 1UL; /* File Counter Holder */ register INT i, k, n; /* Loop Counter */ switch ( msg ) { /* Perform window initialization */ case WM_CREATE : hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE); WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE)); memset(&lbwcd, 0, sizeof(LISTBOXCDATA)); lbwcd.cb = sizeof(LISTBOXCDATA); lbwcd.ulVersion = LBV_110; lbwcd.vdata.lbcd1_1.flExtStyles = LSXS_CHECKBOX | LSXS_EDITABLE; hwndList1 = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE, 10L, 10L, 100L, 175L, hWnd, HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL); hwndListx = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE, 125L, 10L, 100L, 175L, hWnd, HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL); hwndList2 = WinCreateWindow(hWnd, "ListBoxWindow", "", WS_VISIBLE, 10L, 190L, 250L, 200L, hWnd, HWND_TOP, 1025UL, (PVOID)&lbwcd, (PVOID)NULL); WinSendMsg(hwndList1, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_SINGLECLICK), MPFROMP("ahooga.wav")); WinSendMsg(hwndListx, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_DOUBLECLICK), MPFROMP("flush.wav")); hwndListA = WinCreateWindow(hWnd, WC_LISTBOX, "", LS_OWNERDRAW | LS_HORZSCROLL | LS_MULTIPLESEL | WS_VISIBLE, 275L, 10L, 100L, 175L, hWnd, HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL); /* Sub-class the default window procedure with */ /* new one which will handle specific messages */ /* allowing better control over the sizing frame */ hwndListB = WinCreateWindow(hWnd, WC_LISTBOX, "", WS_VISIBLE | LS_EXTENDEDSEL, 275L, 190L, 250L, 200L, hWnd, HWND_TOP, 1027UL, (PVOID)NULL, (PVOID)NULL); for ( i = 0; i < 10; i++ ) { sprintf(szFile, "Item %04d Item %04d Item %04d", i, i, i); WinSendMsg(hwndListx, LM_INSERTITEM, MPFROMLONG(LIT_END), MPFROMP(szFile)); } n = (INT)WinSendMsg(hwndList2, LMX_CALCLINECOUNT, MPFROMLONG(175L), 0L); k = 0; WinSendMsg(hwndList2, LM_SETITEMHEIGHT, MPFROMLONG(36L), 0L); if ( !DosFindFirst("*.*", &hDir, FILE_NORMAL, (PVOID)&findbuf, sizeof(FILEFINDBUF3), &ulFileCnt, FIL_STANDARD) ) { do { WinSendMsg(hwndList2, LM_INSERTITEM, MPFROMLONG(LIT_SORTDESCENDING), MPFROMP(findbuf.achName)); WinSendMsg(hwndList1, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); if ( ++k > n ) WinSendMsg(hwndList2, LM_SETTOPINDEX, MPFROMLONG(k - n), 0L); WinSendMsg(hwndListB, LM_INSERTITEM, MPFROMLONG(LIT_SORTDESCENDING), MPFROMP(findbuf.achName)); WinSendMsg(hwndListA, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); } while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) ); DosFindClose(hDir); } break; case WM_BUTTON1DOWN : WinEnableWindowUpdate(hwndListA, FALSE); WinEnableWindowUpdate(hwndList1, FALSE); WinSendMsg(hwndListA, LM_DELETEALL, 0L, 0L); WinSendMsg(hwndList1, LM_DELETEALL, 0L, 0L); i = 0; if ( !DosFindFirst("*.*", &hDir, FILE_NORMAL, (PVOID)&findbuf, sizeof(FILEFINDBUF3), &ulFileCnt, FIL_STANDARD) ) { do { WinSendMsg(hwndListA, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); WinSendMsg(hwndList1, LM_INSERTITEM, MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName)); ++i; } while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) ); DosFindClose(hDir); } WinShowWindow(hwndListA, TRUE); WinShowWindow(hwndList1, TRUE); while ( i ) { if ( i % 2 ) { WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE)); WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE)); } --i; } break; case WM_CONTROL : switch ( SHORT2FROMMP(mp1) ) { /* Process double click on a List Box */ case LN_SELECT : switch ( SHORT1FROMMP(mp1) ) { case 1024UL : /* WinAlarm(HWND_DESKTOP, WA_NOTE); */ break; case 1027UL : /* WinAlarm(HWND_DESKTOP, WA_ERROR); */ break; } break; } break; case WM_MEASUREITEM : GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm); WinReleasePS(hPS); return(MRFROMLONG(fm.lMaxBaselineExt)); /* Draw a list box item */ case WM_DRAWITEM : if ( SHORT1FROMMP(mp1) == 1024 ) hwndListBox = hwndList1; else if ( SHORT1FROMMP(mp1) == 1026 ) hwndListBox = hwndListA; /* Point to Owner Item information */ poi = (POWNERITEM)mp2; GpiCreateLogColorTable(poi->hps, 0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL); i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXTLENGTH, MPFROMLONG(poi->idItem), 0L)); i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXT, MPFROM2SHORT(poi->idItem, CCHMAXPATH), MPFROMP(szFile))); /* Check to see if item to be drawn or */ /* highlighted */ if ( poi->fsState != poi->fsStateOld ) { WinFillRect(poi->hps, &poi->rclItem, RGBCLR_DIALOGBACKGROUND); if ( poi->fsState ) WinDrawText(poi->hps, -1L, szFile, &poi->rclItem, RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER | DT_ERASERECT); /* Set item highlighting by inverting the items */ /* rectangle colour */ WinInvertRect(poi->hps, &poi->rclItem); if ( !poi->fsState ) WinDrawText(poi->hps, -1L, szFile, &poi->rclItem, RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER | DT_ERASERECT); poi->fsState = poi->fsStateOld = 0; } else { /* Item needs to be drawn, get item rectangle */ /* item position */ WinFillRect(poi->hps, &poi->rclItem, RGBCLR_DIALOGBACKGROUND); WinDrawText(poi->hps, -1L, szFile, &poi->rclItem, RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER | DT_ERASERECT); } return(MRFROMLONG(TRUE)); case WM_BUTTON1DBLCLK : i = 0; if ( !DosFindFirst("*.*", &hDir, FILE_NORMAL, (PVOID)&findbuf, sizeof(FILEFINDBUF3), &ulFileCnt, FIL_STANDARD) ) { do { ++i; } while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) ); DosFindClose(hDir); } while ( i ) { if ( i % 2 ) { WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE)); WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE)); } --i; } break; case WM_BUTTON2DOWN : for ( i = 0; i < 5; i++ ) WinSendMsg(hwndListx, LM_DELETEITEM, MPFROMSHORT(2), 0L); #if 0 WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(LIT_NONE), MPFROMLONG(TRUE)); i = LIT_FIRST; while ( (i = (INT)LONGFROMMR(WinSendMsg(hwndList1, LM_QUERYSELECTION, MPFROMLONG(i), 0L))) != LIT_NONE ) WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i), MPFROMLONG(FALSE)); #endif break; /* Erase background */ case WM_ERASEBACKGROUND : WinQueryWindowRect(hWnd, &rcl); WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND); break; /* Paint the main client window */ case WM_PAINT : WinSetPointer(HWND_DESKTOP, hptrWait); WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL, &rcl), &rcl, SYSCLR_DIALOGBACKGROUND); WinEndPaint(hPS); WinSetPointer(HWND_DESKTOP, hptrArrow); break; /* Close Down */ case WM_CLOSE : WinPostMsg(hWnd, WM_QUIT, 0L, 0L); break; case WM_DESTROY : WinDestroyPointer(hptrArrow); WinDestroyPointer(hptrWait); break; /* Default message processing */ default: return(WinDefWindowProc(hWnd, msg, mp1, mp2)); } return(0L); }
static MRESULT EXPENTRY LinkLabelProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { linkData *ld = (linkData *)WinQueryWindowULong( hwnd, QWL_USER ); switch ( msg ) { case WM_PAINT: { FONTMETRICS fm; FATTRS fat; HPS hps; ULONG style; char *text = (char *)malloc( MAXTEXTLEN ); WinQueryWindowText( hwnd, MAXTEXTLEN, text); hps = WinBeginPaint( hwnd , 0L , 0L ); GpiQueryFontMetrics( hps , sizeof( FONTMETRICS ) , &fm ); memset( &fat , 0 , sizeof( fat ) ); fat.usRecordLength = sizeof( FATTRS ); fat.lMatch = fm.lMatch; fat.fsSelection = FATTR_SEL_UNDERSCORE; strcpy( fat.szFacename , fm.szFacename ); GpiDeleteSetId( hps , 1 ); GpiCreateLogFont( hps , 0 , 1 , &fat ); GpiSetCharSet( hps , 1 ); WinQueryWindowRect( hwnd , &ld->textRect ); style = WinQueryWindowULong( hwnd, QWL_STYLE ); style &= DT_LEFT|DT_CENTER|DT_RIGHT|DT_TOP|DT_VCENTER|DT_BOTTOM; WinDrawText( hps, -1, text, &ld->textRect, CLR_BLUE, SYSCLR_DIALOGBACKGROUND, style | DT_ERASERECT | DT_UNDERSCORE ); WinDrawText( hps, -1, text, &ld->textRect, CLR_BLUE, SYSCLR_DIALOGBACKGROUND, style | DT_QUERYEXTENT | DT_UNDERSCORE ); WinEndPaint( hps ); free( text ); } return (MRESULT)FALSE; case WM_MOUSEMOVE: { if ( handPtr != NULLHANDLE ) { POINTL ptl; ptl.x = SHORT1FROMMP( mp1 ); ptl.y = SHORT2FROMMP( mp1 ); if ( WinPtInRect( WinQueryAnchorBlock( hwnd ), &ld->textRect, &ptl) ) { WinSetPointer( HWND_DESKTOP, handPtr ); return (MRESULT)FALSE; } } } break; case WM_BUTTON1CLICK: { PROGDETAILS pd; char *text; POINTL ptl; if ( strcmp( browserExe, "" ) == 0 ) break; ptl.x = SHORT1FROMMP( mp1 ); ptl.y = SHORT2FROMMP( mp1 ); if ( !WinPtInRect( WinQueryAnchorBlock( hwnd ), &ld->textRect, &ptl) ) break; if ( ld->url == NULL ) { text = (char *)malloc( MAXTEXTLEN ); WinQueryWindowText( hwnd, MAXTEXTLEN, text); } else text = strdup( ld->url ); pd.Length = sizeof( PROGDETAILS ); pd.progt.progc = PROG_DEFAULT; pd.progt.fbVisible = SHE_VISIBLE; pd.pszTitle = NULL; pd.pszExecutable = browserExe; pd.pszParameters = NULL; pd.pszStartupDir = ( browserDir[0] == 0 ) ? NULL : browserDir; pd.pszIcon = NULL; pd.pszEnvironment = NULL; pd.swpInitial.fl = SWP_ACTIVATE; pd.swpInitial.cy = 0; pd.swpInitial.cx = 0; pd.swpInitial.y = 0; pd.swpInitial.x = 0; pd.swpInitial.hwndInsertBehind = HWND_TOP; pd.swpInitial.hwnd = NULLHANDLE; pd.swpInitial.ulReserved1 = 0; pd.swpInitial.ulReserved2 = 0; WinStartApp( NULLHANDLE , &pd , text , NULL , 0 ); free( text ); } break; case WM_DESTROY: ld->labelProc( hwnd, msg, mp1, mp2 ); if ( ld->url != NULL ) free( ld->url ); free( ld ); return (MRESULT)FALSE; } return ld->labelProc( hwnd, msg, mp1, mp2 ); }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static INT aiPuzzle[NUMROWS][NUMCOLS], iBlankRow, iBlankCol, cxSquare, cySquare ; CHAR szNum[10] ; HPS hps ; HWND hwndFrame ; INT iRow, iCol, iMouseRow, iMouseCol, i ; POINTL ptl ; RECTL rcl, rclInvalid, rclIntersect ; SIZEL sizl ; switch (msg) { case WM_CREATE: // Calculate square size in pixels hps = WinGetPS (hwnd) ; sizl.cx = sizl.cy = 0 ; GpiSetPS (hps, &sizl, PU_LOENGLISH) ; ptl.x = SQUARESIZE ; ptl.y = SQUARESIZE ; GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ; WinReleasePS (hps) ; cxSquare = ptl.x ; cySquare = ptl.y ; // Calculate client window size and position rcl.xLeft = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - NUMCOLS * cxSquare) / 2 ; rcl.yBottom = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - NUMROWS * cySquare) / 2 ; rcl.xRight = rcl.xLeft + NUMCOLS * cxSquare ; rcl.yTop = rcl.yBottom + NUMROWS * cySquare ; // Set frame window position and size hwndFrame = WinQueryWindow (hwnd, QW_PARENT) ; WinCalcFrameRect (hwndFrame, &rcl, FALSE) ; WinSetWindowPos (hwndFrame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE | SWP_ACTIVATE) ; // Initialize the aiPuzzle array WinSendMsg (hwnd, WM_COMMAND, MPFROMSHORT (IDM_NORMAL), NULL) ; return 0 ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULLHANDLE, &rclInvalid) ; // Draw the squares for (iRow = NUMROWS - 1 ; iRow >= 0 ; iRow--) for (iCol = 0 ; iCol < NUMCOLS ; iCol++) { rcl.xLeft = cxSquare * iCol ; rcl.yBottom = cySquare * iRow ; rcl.xRight = rcl.xLeft + cxSquare ; rcl.yTop = rcl.yBottom + cySquare ; if (!WinIntersectRect (0, &rclIntersect, &rcl, &rclInvalid)) continue ; if (iRow == iBlankRow && iCol == iBlankCol) WinFillRect (hps, &rcl, CLR_BLACK) ; else { WinDrawBorder (hps, &rcl, 5, 5, CLR_PALEGRAY, CLR_DARKGRAY, DB_STANDARD | DB_INTERIOR) ; WinDrawBorder (hps, &rcl, 2, 2, CLR_BLACK, 0L, DB_STANDARD) ; sprintf (szNum, "%d", aiPuzzle[iRow][iCol]) ; WinDrawText (hps, -1, szNum, &rcl, CLR_WHITE, CLR_DARKGRAY, DT_CENTER | DT_VCENTER) ; } } WinEndPaint (hps) ; return 0 ; case WM_BUTTON1DOWN: iMouseCol = MOUSEMSG(&msg)->x / cxSquare ; iMouseRow = MOUSEMSG(&msg)->y / cySquare ; // Check if mouse was in valid area if ( iMouseRow < 0 || iMouseCol < 0 || iMouseRow >= NUMROWS || iMouseCol >= NUMCOLS || (iMouseRow != iBlankRow && iMouseCol != iBlankCol) || (iMouseRow == iBlankRow && iMouseCol == iBlankCol)) break ; // Move a row right or left if (iMouseRow == iBlankRow) { if (iMouseCol < iBlankCol) for (iCol = iBlankCol ; iCol > iMouseCol ; iCol--) aiPuzzle[iBlankRow][iCol] = aiPuzzle[iBlankRow][iCol - 1] ; else for (iCol = iBlankCol ; iCol < iMouseCol ; iCol++) aiPuzzle[iBlankRow][iCol] = aiPuzzle[iBlankRow][iCol + 1] ; } // Move a column up or down else { if (iMouseRow < iBlankRow) for (iRow = iBlankRow ; iRow > iMouseRow ; iRow--) aiPuzzle[iRow][iBlankCol] = aiPuzzle[iRow - 1][iBlankCol] ; else for (iRow = iBlankRow ; iRow < iMouseRow ; iRow++) aiPuzzle[iRow][iBlankCol] = aiPuzzle[iRow + 1][iBlankCol] ; } // Calculate invalid rectangle rcl.xLeft = cxSquare * min (iMouseCol, iBlankCol) ; rcl.yBottom = cySquare * min (iMouseRow, iBlankRow) ; rcl.xRight = cxSquare * (max (iMouseCol, iBlankCol) + 1) ; rcl.yTop = cySquare * (max (iMouseRow, iBlankRow) + 1) ; // Set new array and blank values iBlankRow = iMouseRow ; iBlankCol = iMouseCol ; aiPuzzle[iBlankRow][iBlankCol] = 0 ; // Invalidate rectangle WinInvalidateRect (hwnd, &rcl, FALSE) ; break ; case WM_CHAR: if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) || CHARMSG(&msg)->fs & KC_KEYUP) return 0 ; // Mimic a WM_BUTTON1DOWN message iMouseCol = iBlankCol ; iMouseRow = iBlankRow ; switch (CHARMSG(&msg)->vkey) { case VK_LEFT: iMouseCol++ ; break ; case VK_RIGHT: iMouseCol-- ; break ; case VK_UP: iMouseRow-- ; break ; case VK_DOWN: iMouseRow++ ; break ; default: return 0 ; } WinSendMsg (hwnd, WM_BUTTON1DOWN, MPFROM2SHORT (iMouseCol * cxSquare, iMouseRow * cySquare), NULL) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { // Initialize aiPuzzle array case IDM_NORMAL: case IDM_INVERT: for (iRow = 0 ; iRow < NUMROWS ; iRow++) for (iCol = 0 ; iCol < NUMCOLS ; iCol++) aiPuzzle[iRow][iCol] = iCol + 1 + NUMCOLS * (NUMROWS - iRow - 1) ; if (COMMANDMSG(&msg)->cmd == IDM_INVERT) { aiPuzzle[0][NUMCOLS-2] = NUMCOLS * NUMROWS - 2 ; aiPuzzle[0][NUMCOLS-3] = NUMCOLS * NUMROWS - 1 ; } aiPuzzle[iBlankRow = 0][iBlankCol = NUMCOLS - 1] = 0 ; WinInvalidateRect (hwnd, NULL, FALSE) ; return 0 ; // Randomly scramble the squares case IDM_SCRAMBLE: WinSetPointer (HWND_DESKTOP, WinQuerySysPointer ( HWND_DESKTOP, SPTR_WAIT, FALSE)) ; srand ((int) WinGetCurrentTime (0)) ; for (i = 0 ; i < SCRAMBLEREP ; i++) { WinSendMsg (hwnd, WM_BUTTON1DOWN, MPFROM2SHORT (rand() % NUMCOLS * cxSquare, iBlankRow * cySquare), NULL) ; WinUpdateWindow (hwnd) ; WinSendMsg (hwnd, WM_BUTTON1DOWN, MPFROM2SHORT (iBlankCol * cxSquare, rand() % NUMROWS * cySquare), NULL) ; WinUpdateWindow (hwnd) ; } WinSetPointer (HWND_DESKTOP, WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE)); return 0 ; } break ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
static MRESULT APIENTRY Button1Down ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) { /*************************************************************************** * Find the instance data. * ***************************************************************************/ PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ; /*************************************************************************** * Find out where the mouse touched. * ***************************************************************************/ RECTL Rectangle ; WinQueryWindowRect ( Window, &Rectangle ) ; WorkSpace PS ( "HRuler::Button1Down", 0, Window, Data->pDevice, int(Data->Metric) ) ; PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ; POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ; PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ; PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ; POINTL ButtonSize = { 8, 8 } ; PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ; #ifdef DEBUG Log ( "HRuler::Button1Down: Mouse at %i,%i (%i,%i). Rectangle %i,%i-%i,%i. ButtonSize %i.%i (8x8).", Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop, ButtonSize.x, ButtonSize.y ) ; #endif /*************************************************************************** * If the mouse isn't touching in the button area, return. * ***************************************************************************/ if ( Mouse.y < Rectangle.yTop - ButtonSize.y ) { Sys_BeepNote ( ) ; return ( MRFROMSHORT ( FALSE ) ) ; } /* endif */ /*************************************************************************** * If the mouse is beyond the margins, return. * ***************************************************************************/ if ( ( Mouse.x < Data->LeftMargin ) OR ( Mouse.x > Data->RightMargin+ButtonSize.x ) ) { Sys_BeepNote ( ) ; return ( MRFROMSHORT ( FALSE ) ) ; } /* endif */ /*************************************************************************** * If mouse is touching the left margin button, set mode to MOVELEFT. * ***************************************************************************/ if ( ( Mouse.x >= Data->LeftMargin ) AND ( Mouse.x <= Data->LeftMargin+ButtonSize.x ) ) { Data->Mode = MOVELEFT ; Data->Ptr = Data->MarginPtr ; } /* endif */ /*************************************************************************** * If mouse is touching the right margin button, set mode to MOVERIGHT. * ***************************************************************************/ else if ( ( Mouse.x >= Data->RightMargin-ButtonSize.x ) AND ( Mouse.x <= Data->RightMargin ) ) { Data->Mode = MOVERIGHT ; Data->Ptr = Data->MarginPtr ; } /* endif */ /*************************************************************************** * Else, find which tab-stop, if any, we're touching. * ***************************************************************************/ else { for ( int i=0; i<Data->TabCount; i++ ) { if ( ( Mouse.x >= Data->Tabs[i] ) AND ( Mouse.x <= Data->Tabs[i]+ButtonSize.x ) ) { Data->Mode = MOVETAB ; Data->TabIndex = USHORT ( i ) ; break ; } /* endif */ } /* endfor */ if ( i >= Data->TabCount ) { Data->Mode = SETTAB ; } /* endif */ Data->Ptr = Data->TabstopPtr ; } /* endif */ /*************************************************************************** * Capture the mouse. * ***************************************************************************/ Data->Capture = TRUE ; Sys_SetCapture ( Window ) ; /*************************************************************************** * Set the new mouse pointer. * ***************************************************************************/ WinSetPointer ( HWND_DESKTOP, Data->Ptr ) ; /*************************************************************************** * Get the keyboard focus. * ***************************************************************************/ Data->HadFocus = WinQueryFocus ( HWND_DESKTOP ) ; Sys_SetFocus ( Window ) ; /*************************************************************************** * Save the current hairline position. * ***************************************************************************/ Data->Tick = TICK(Mouse.x) ; /*************************************************************************** * Draw a hairline showing the current position. * ***************************************************************************/ PS.SetMix ( FM_INVERT ) ; PS.SetLineType ( LINETYPE_ALTERNATE ) ; POINTL Point = { Data->Tick, Rectangle.yBottom } ; PS.Move ( Point ) ; Point.y = Rectangle.yTop ; PS.DrawLine ( Point ) ; /*************************************************************************** * We're done. * ***************************************************************************/ return ( MRFROMSHORT ( TRUE ) ) ; }
VOID main() { if ( (hab = WinInitialize( 0L )) == (HAB) NULL ){ printf( "ToolBar Error: WinInitialize failed \n" ); return; } else { if ( (hmq = WinCreateMsgQueue( hab, 0 )) == (HMQ) NULL ){ printf( "ToolBar Error: WinCreateMsgQueue failed \n" ); return; } else { ULONG fulCreate= FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_SHELLPOSITION | FCF_ICON ; /* * Note: no menu was specificed in create flags */ WinSetPointer( HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,TRUE)); WinRegisterClass(hab, szClassName, (PFNWP)MainWindowProc, CS_SIZEREDRAW, 0); hwndFrame = WinCreateStdWindow(HWND_DESKTOP, 0L, (PULONG)&fulCreate, szClassName , szMainTitle, 0L, (HMODULE)NULL, ID_MAIN_WIN, &hwndClient); if ( hwndFrame == NULLHANDLE ) { ShowErrorWindow( "Error creating Main window !", TRUE ); } else { PFNWP pfnwpOldFrameProc ; /* --------- subclass frame proc ------------------ */ pfnwpOldFrameProc = WinSubclassWindow( hwndFrame, (PFNWP) NewFrameProc ); if ( pfnwpOldFrameProc == (PFNWP)0L ){ ShowErrorWindow( "Error subclassing frame window !", TRUE ); } else { PID pid ; SWCNTRL swCntrl; HSWITCH hSwitch ; LONG lRGB; /* ------- store old frame proc with handle ------- */ WinSetWindowULong( hwndFrame, QWL_USER, (ULONG) pfnwpOldFrameProc ); /* ------------------ load menus ------------------- */ hwndMenuBar = WinLoadMenu( hwndFrame, (HMODULE)NULL, MID_MENUBAR ); hwndToolBar = WinLoadMenu( hwndFrame, (HMODULE)NULL, MID_TOOLBAR ); /* * Note that the last menu loaded, the toolbar, is the * one that is associated with the frame as "the" menu. * this means that hwndMenuBar is the only link to the * regular action bar, so hang onto it tightly */ /* ---------- set toolbar background color ---------- */ lRGB = WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONDARK, 0L ); WinSetPresParam( hwndToolBar, PP_BACKGROUNDCOLOR, 4L, (PVOID)lRGB ); /* --------- set window size and pos -------------- */ WinSetWindowPos( hwndFrame, HWND_TOP, 0, 0, 370, 300, SWP_SIZE | SWP_SHOW | SWP_ACTIVATE ); /* ----------- add program to tasklist --------------- */ WinQueryWindowProcess( hwndFrame, &pid, NULL ); swCntrl.hwnd = hwndFrame ; swCntrl.hwndIcon = (HWND) NULL ; swCntrl.hprog = (HPROGRAM) NULL ; swCntrl.idProcess = pid ; swCntrl.idSession = (LONG) NULL ; swCntrl.uchVisibility = SWL_VISIBLE ; swCntrl.fbJump = SWL_JUMPABLE ; sprintf( swCntrl.szSwtitle, szMainTitle ); hSwitch = WinAddSwitchEntry((PSWCNTRL)&swCntrl); WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE)); /* ---------- start the main processing loop ----------- */ while (WinGetMsg(hab, &qmsg,NULLHANDLE,0,0)){ WinDispatchMsg(hab, &qmsg); } WinRemoveSwitchEntry( hSwitch ); } /* end of else ( pfnwpOldFrameProc ) */ WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE)); WinDestroyWindow(hwndFrame); } /* end of else (hwndFrame == NULLHANDLE) */ WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE)); WinDestroyMsgQueue(hmq); } /* end of else ( ...WinCreateMsgQueue() */ WinTerminate(hab); } /* end of else (...WinInitialize(NULL) */ } /* end of main() */
VOID MP3DISPLAY :: RemoveAll (VOID) { #ifdef _DEBUGLOG_ fputs ("\nRemoveAll ()\n", pfileLog); #endif if (! hwnd || ! FilesInList ()) return; // confirm operation if (WinMessageBox (HWND_DESKTOP, hwnd, #ifdef _MULTILANGUAGES_ RSTR (IDS_REALLYREMOVETAGS), RSTR (IDS_REALLYREMOVETAGSHEADING), #else "Really remove the tags of all selected files?", "REALLY REMOVE?", #endif 0L, MB_OKCANCEL | MB_QUERY | MB_DEFBUTTON2 | MB_MOVEABLE) != MBID_OK) return; if (QueryMP3 ()) { delete QueryMP3 (); SetMP3 (NULL); } // set mouse-ptr to "wait" shape HPOINTER hptr = WinQueryPointer (HWND_DESKTOP); WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE)); // do the thing CHAR ach[_MAX_PATH], ach2[_MAX_PATH+31]; ULONG c = 0L; for (ULONG i = 0; i < CountFilesInList (); i++) { QueryFile (ach, sizeof (ach), i); if ((pmp3 = new MP3 (ach))) { if (pmp3->IsTagged ()) { #ifdef _MULTILANGUAGES_ sprintf (ach2, RSTR (IDS_REMOVINGFORMAT), ach); #else sprintf (ach2, "Removing - %s", ach); #endif if (pmp3->RemoveTag ()) c++; } else #ifdef _MULTILANGUAGES_ sprintf (ach2, RSTR (IDS_IGNORINGFORMAT), ach); #else sprintf (ach2, "Ignoring - %s", ach); #endif delete pmp3; } WinSetWindowText (hwnd, ach2); } if (pset->NotifyRemove ()) { #ifdef _MULTILANGUAGES_ // tell user what has been done if (c < CountFilesInList ()) Notify (RSTR (IDS_TAGSREMOVEDHEADING), RSTR (IDS_SOMETAGSREMOVED), c); else Notify (RSTR (IDS_TAGSREMOVEDHEADING), RSTR (IDS_ALLTAGSREMOVED)); #else // tell user what has been done if (c < CountFilesInList ()) Notify ("SOME TAGS REMOVED", "Tags have been removed from %ld selected files (The " "others probably were read only or had no tag)", c); else Notify ("ALL TAGS REMOVED", "Tags have been removed from all selected files."); #endif } // reload the current file and refresh the display SetMP3 (NULL); Refresh (); // set mouse-ptr to normal shape WinSetPointer (HWND_DESKTOP, hptr); WinSetWindowText (hwnd, PSZ_NAMEVERSION); }