void HandleSpinValue( HWND hWindow, BOOL bInTopRect, BOOL bInBottomRect) { LFIXED fValue; int iValue; BOOL Bool; STRING szString; long l; long step; step = GetWindowLong( hWindow, GWL_SPINSTEP ); if ( GetWindowWord( hWindow, GWW_SPINTYPE ) ) { // Its a fixed spinner... fValue = GetWindowLong(hWindow, GWL_FSPINVALUE); if (bInTopRect) fValue = BumpFixedSpinnerValue(fValue, TRUE, step); else if (bInBottomRect) fValue = BumpFixedSpinnerValue(fValue, FALSE, step); SetDlgItemSpinFixed(GetParent(hWindow), GET_WINDOW_ID(hWindow), fValue, step == 0); } else { iValue = GetDlgItemInt( GetParent(hWindow), GET_WINDOW_ID(hWindow), &Bool, YES ); if ( !iValue && !Bool) { // if zero from the control, check to see if it's empty (which is OK) GetDlgItemText( GetParent(hWindow),GET_WINDOW_ID(hWindow), szString, MAX_STR_LEN); l = atol(szString); iValue = mbound(l, INT_MIN, INT_MAX); } if (step == 0) { if ( bInTopRect ) iValue++; if ( bInBottomRect ) iValue--; } else { if ( bInTopRect ) iValue += step; if ( bInBottomRect ) iValue -= step; } SetDlgItemSpin( GetParent(hWindow), GET_WINDOW_ID(hWindow), iValue, YES ); } }
static BOOL Video_OnCreate(HWND hWindow, LPCREATESTRUCT lpCreateStruct) /***********************************************************************/ { BOOL fRemap; LPVIDEO lpVideo; if ( !(lpVideo = (LPVIDEO)AllocX( sizeof(VIDEO), GMEM_ZEROINIT|GMEM_SHARE )) ) return( FALSE ); SetWindowLong( hWindow, GWL_DATAPTR, (long)lpVideo ); ITEMID id; if ( !(id = GetWindowWord( hWindow, GWW_ICONID )) ) id = GET_WINDOW_ID( hWindow ); lpVideo->lpAllShots = Video_GetShotData( id, &lpVideo->iNumShots, &fRemap ); lpVideo->lCurrentShot = lpVideo->lPrevShot = (lDefaultShot ? lDefaultShot : 1 ); lDefaultShot = 0; lpVideo->lPrevFrame = 0; // Remap the shot table to make all entries sequential if (fRemap) Video_RemapShotTable( hWindow ); Video_CheckDumpShotTable(id, lpVideo->lpAllShots, lpVideo->iNumShots); LPSHOT lpShot = Video_GetShotPtr( lpVideo, lpVideo->lCurrentShot ); return( Video_Open( hWindow, lpVideo, (lpShot ? lpShot->wDisk : 1), (lpShot ? lpShot->lStartFrame : 0) ) ); }
LOCAL BOOL Bmulti_ComputeSize( HWND hControl, LPINT lpDX, LPINT lpDY ) /***********************************************************************/ { ITEMID idControl; LPBITMAPINFO lpDIB; HGLOBAL hResource; if ( !(idControl = GetWindowWord( hControl, GWW_ICONID )) ) idControl = GET_WINDOW_ID( hControl ); if ( !(hResource = (HGLOBAL)FindResource (GetWindowInstance(hControl), MAKEINTRESOURCE(idControl), RT_BITMAP) ) ) return( NO ); if ( !(hResource = LoadResource (GetWindowInstance(hControl), (HRSRC)hResource) ) ) return( NO ); if ( !(lpDIB = (LPBITMAPINFO)LockResource (hResource) ) ) return( NO ); // Make sure that the DIB is uncompressed if ( lpDX ) *lpDX = (int)lpDIB->bmiHeader.biWidth; if ( lpDY ) *lpDY = (int)abs(lpDIB->bmiHeader.biHeight); UnlockResource( hResource ); FreeResource( hResource ); return( YES ); }
//*************************************************************************** UINT Story_OnMCINotify( HWND hWindow, UINT codeNotify, HMCI hDevice ) //*************************************************************************** { PSTORY pStory = GetStory(hWindow); switch( codeNotify ) { case MCI_NOTIFY_SUCCESSFUL: { if (pStory && pStory->m_fPlaying) { pStory->Reset(); FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 2, SendMessage); } return FALSE; } case MCI_NOTIFY_ABORTED: // wParam == 4 { // aborted msg sent during playback, if we get a // seek, step, stop, or full screen playback escape command. // continue playing after a seek or step, unless // escaping from a full screen playback return( FALSE ); } case MCI_NOTIFY_SUPERSEDED: // wParam == 2 case MCI_NOTIFY_FAILURE: // wParam == 8 { // superseded msg sent during playback if we get a new play command return( FALSE ); } } return( FALSE ); }
static void Video_OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { LPVIDEO lpVideo; RECT rWindow; if ( SHIFT ) return; if ( bTrack ) return; SetCapture( hWindow ); bTrack = TRUE; #ifdef _DEBUG if ( GetFocus() != hWindow ) SetFocus( hWindow ); #endif if ( !(lpVideo = (LPVIDEO)GetWindowLong( hWindow, GWL_DATAPTR )) ) return; if ( !lpVideo->lpAllShots ) // if no jump table... { FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), 0, 0, SendMessage ); return; } // Process the proper event based on the "hotspot" that was clicked GetClientRect( hWindow, &rWindow ); x = (x * 10) / RectWidth( &rWindow ); y = (y * 10) / RectHeight( &rWindow ); int iEventCode = PtInHotspot( lpVideo, x, y, YES ); if ( iEventCode ) Video_ProcessEvent( hWindow, lpVideo, iEventCode ); }
LOCAL BOOL ComputeDIBControlSize (HWND hControl, LPINT lpDX, LPINT lpDY) /***********************************************************************/ { ITEMID idControl; LPBITMAPINFO lpDIB; HGLOBAL hResource; LPHSLIDERINFO lpInfo; if (! (lpInfo = (LPHSLIDERINFO)GetWindowLong( hControl, GWL_DATAPTR )) ) return FALSE; if (! (idControl = GetWindowWord (hControl, GWW_ICONID) ) ) idControl = GET_WINDOW_ID (hControl); if (! (hResource = (HGLOBAL)FindResource (GetApp()->GetInstance(), MAKEINTRESOURCE(idControl), RT_BITMAP) ) ) return (FALSE); if (! (hResource = LoadResource (GetApp()->GetInstance(), (HRSRC)hResource) ) ) return (FALSE); if (! (lpDIB = (LPBITMAPINFO)LockResource (hResource) ) ) return (FALSE); RECT rClient; GetClientRect (hControl, & rClient); if ( lpDX ) *lpDX = rClient.right - rClient.left; if ( lpDY ) *lpDY = rClient.bottom - rClient.top; // Set up the DIB rectangle if (lpInfo) { lpInfo->iCenter = (rClient.bottom - rClient.top) / 2; lpInfo->rSlider.top = (rClient.bottom - rClient.top) / 2 - lpInfo->iSlideWidth / 2; lpInfo->rSlider.left = rClient.left; lpInfo->rSlider.right = rClient.right; lpInfo->rSlider.bottom = (rClient.bottom - rClient.top) / 2 + lpInfo->iSlideWidth / 2; lpInfo->rBitmap.top = 0; lpInfo->rBitmap.left = 0; lpInfo->rBitmap.right = lpInfo->rBitmap.left + (int)lpDIB->bmiHeader.biWidth; lpInfo->rBitmap.bottom = lpInfo->rBitmap.top + (int)abs(lpDIB->bmiHeader.biHeight); } UnlockResource (hResource); FreeResource (hResource); return (TRUE); }
LOCAL void Hotspot_OnTimer(HWND hWindow, UINT id) /***********************************************************************/ { // Timer went off, so execute the same as in WM_LBUTTONDOWN STRING szScene; KillTimer( hWindow, id ); GetWindowText( hWindow, szScene, sizeof(szScene)-1 ); if ( !(*szScene) ) FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 0, SendMessage); else GetApp()->GotoScene( GetParent(hWindow), latoi(szScene) ); }
LOCAL void Slider_OnLButtonUp(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { LPHSLIDERINFO lpInfo; if (! (lpInfo = (LPHSLIDERINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) ) return; if (! lpInfo->bTrack) return; ReleaseCapture (); lpInfo->bTrack = FALSE; // Send the new setting back to the parent FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), 1, lpInfo->Position, SendMessage ); }
LOCAL void Hotspot_OnLButtonUp(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { if ( !bTrack ) return; ReleaseCapture(); bTrack = FALSE; if ( bInRect ) { STRING szScene; GetWindowText( hWindow, szScene, sizeof(szScene)-1 ); if ( !(*szScene) ) FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 0, SendMessage); else GetApp()->GotoScene( GetParent(hWindow), latoi(szScene) ); } }
LOCAL void Bmulti_OnLButtonUp(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { DWORD dwStyle; LPBMULTICONTINFO lpInfo; if (! (lpInfo = (LPBMULTICONTINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) ) return; if (! lpInfo->bTrack) return; ReleaseCapture(); lpInfo->bTrack = FALSE; dwStyle = GetWindowLong(hWindow, GWL_STYLE); InvalidateRect(hWindow, NULL, FALSE); if (lpInfo->bInRect) FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 0, SendMessage); }
LOCAL BOOL SetupMeterControlInfo(HWND hControl, LPINT lpDX, LPINT lpDY) /***********************************************************************/ { ITEMID idControl; LPBITMAPINFO lpDIB; HGLOBAL hResource; LPMETERCONTINFO lpInfo; if (!(lpInfo = (LPMETERCONTINFO)GetWindowLong(hControl, GWL_DATAPTR) ) ) return FALSE; if (!(idControl = GetWindowWord(hControl, GWW_ICONID))) idControl = GET_WINDOW_ID(hControl); if (!(hResource = (HGLOBAL)FindResource(GetWindowInstance(hControl), MAKEINTRESOURCE(idControl), RT_BITMAP) ) ) return(FALSE); if (!(hResource = LoadResource(GetWindowInstance (hControl), (HRSRC)hResource) ) ) return (FALSE); if (! (lpDIB = (LPBITMAPINFO)LockResource (hResource) ) ) return (FALSE); // Make sure that the DIB is uncompressed if (lpDX) * lpDX = (int)lpDIB->bmiHeader.biWidth; if (lpDY) * lpDY = (int)abs (lpDIB->bmiHeader.biHeight); // Set up the DIB rectangle if (lpInfo) { lpInfo->rBitmap.top = 0; lpInfo->rBitmap.left = 0; lpInfo->rBitmap.right = lpInfo->rBitmap.left + (int)lpDIB->bmiHeader.biWidth; lpInfo->rBitmap.bottom = lpInfo->rBitmap.top + (int)abs(lpDIB->bmiHeader.biHeight); } UnlockResource (hResource); FreeResource (hResource); return (TRUE); }
LOCAL void Slider_OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { LPHSLIDERINFO lpInfo; if ( !(lpInfo = (LPHSLIDERINFO)GetWindowLong( hWindow, GWL_DATAPTR )) ) return; if ( SHIFT ) return; if ( lpInfo->bTrack ) return; SetCapture( hWindow ); lpInfo->bTrack = TRUE; if ( GetFocus() != hWindow ) SetFocus( hWindow ); lpInfo->bInRect = YES; RECT ClientRect; GetClientRect (hWindow, & ClientRect); x -= ClientRect.left; int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left; x -= (iBmpWidth/2); if ( x < 0 ) x = 0; int iWidth = ClientRect.right - ClientRect.left - iBmpWidth; if ( x > iWidth ) x = iWidth; lpInfo->Position = lpInfo->Min + (int)(((long)x * (lpInfo->Max - lpInfo->Min)) / iWidth); // Send the new setting back to the parent FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), 0, lpInfo->Position, SendMessage ); InvalidateRect (hWindow, & ClientRect, TRUE); }
LOCAL void Story_OnLButtonUp(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { if ( !bTrack ) return; ReleaseCapture(); bTrack = FALSE; DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE); PSTORY pStory = GetStory(hWindow); if (pStory && pStory->m_iHighlight) { HDC hDC = GetDC(hWindow); Story_OnDraw(hWindow, hDC, &pStory->m_lpWordData[pStory->m_iHighlight-1].rArea, FALSE); ReleaseDC(hWindow, hDC); pStory->m_iHighlight = 0; FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 3, SendMessage); } // if ( bInRect ) // { // FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 0, SendMessage); // } }
DWORD CALLBACK EXPORT KeyboardHookProc( /***********************************************************************/ /* Process the F1 key and ask for context sensitive help on the last id to receive a hint */ int nCode, WPARAM wParam, LPARAM lParam) { HWND hWnd; int id; #define STATE_MASK 0xC0000000L #define UP_GOING_DOWN 0x00000000L #define DOWN_GOING_UP 0xC0000000L if ( nCode < 0 || bHelpDisabled || wParam != VK_F1 || (lParam & STATE_MASK) != UP_GOING_DOWN ) return( CallNextHookEx( hKBHook, nCode, wParam, lParam ) ); if ( LBUTTON ) PostMessage ( hWndAstral, WM_KEYDOWN, VK_ESCAPE, 0L ); if ( idItemHelp <= 0 ) { // No help topic if ( hWnd = GetLastActivePopup( hWndAstral ) ) { // Found a modal dialog up if ( !(id = GET_WINDOW_ID( hWnd )) ) if ( !(id = AstralDlgGetID( hWnd )) ); id = AstralDlgGetID( NULL ); idItemHelp = MessageStatus( id, (LPSTR)"", (LPSTR)"" ); } } if ( idItemHelp > 0 ) Help( HELP_CONTEXT, (long)idItemHelp ); else Help( HELP_CONTEXT, (long)Tool.id ); return( TRUE ); }
LOCAL void Story_OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { if ( SHIFT ) return; if ( bTrack ) return; PSTORY pStory = GetStory(hWindow); if (!pStory) return; if (pStory->m_fPlaying) return; if (pStory->m_fPlaying) pStory->StopPlaying(); SetCapture( hWindow ); bTrack = TRUE; if ( GetFocus() != hWindow ) SetFocus( hWindow ); bInRect = YES; DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE); int i; if ((i = pStory->FindHotSpot(x, y)) >= 0) { HDC hDC = GetDC(hWindow); pStory->m_iHighlight = i + 1; Story_OnDraw(hWindow, hDC, &pStory->m_lpWordData[i].rArea, TRUE); if (lstrlen(pStory->m_szStoryFile)) pStory->m_hMCIfile = MCIOpen( App.m_hDeviceWAV, pStory->m_szStoryFile, NULL/*lpAlias*/ ); if ( pStory->m_hMCIfile ) { FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 0, SendMessage); MCIPlay( pStory->m_hMCIfile, NULL, pStory->m_lpWordData[i].dwFrom, pStory->m_lpWordData[i].dwTo ); MCIClose( pStory->m_hMCIfile ); pStory->m_hMCIfile = NULL; } ReleaseDC(hWindow, hDC); } }
LOCAL void Slider_OnMouseMove(HWND hWindow, int x, int y, UINT keyFlags) /***********************************************************************/ { RECT ClientRect; POINT pt; LPHSLIDERINFO lpInfo; if (! (lpInfo = (LPHSLIDERINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) ) return; if (! lpInfo->bTrack) return; GetClientRect (hWindow, & ClientRect); pt.x = x; pt.y = y; if (lpInfo->bInRect == ! PtInRect (& ClientRect, pt ) ) lpInfo->bInRect = ! lpInfo->bInRect; x -= ClientRect.left; int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left; x -= (iBmpWidth/2); if ( x < 0 ) x = 0; int iWidth = ClientRect.right - ClientRect.left - iBmpWidth; if ( x > iWidth ) x = iWidth; lpInfo->Position = lpInfo->Min + (int)(((long)x * (lpInfo->Max - lpInfo->Min)) / iWidth); // Send the new setting back to the parent FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), 0, lpInfo->Position, SendMessage ); InvalidateRect (hWindow, & ClientRect, TRUE); }
LOCAL void Slider_Paint (HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight) /***********************************************************************/ { BOOL bHasFocus, bSelected, bDown; DWORD dwStyle; RECT rSrcArea, rDstArea; POINT ptDst; UINT id; PDIB pdibSrc, pdibDst; HDC hWinGDC; LPHSLIDERINFO lpInfo; if (! (lpInfo = (LPHSLIDERINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) ) return; rSrcArea = *lpRect; rDstArea = *lpRect; MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2 ); LPSCENE lpScene = CScene::GetScene (GetParent (hWindow) ); if (! lpScene) return; if ( !lpScene->GetDIBs( &pdibSrc, &pdibDst, &hWinGDC ) ) return; if ( !pdibSrc || !pdibDst || !hWinGDC ) return; bSelected = GetWindowWord (hWindow, GWW_STATE); dwStyle = GetWindowLong (hWindow, GWL_STYLE); bHasFocus = (GetFocus () == hWindow); bDown = ( bSelected || (lpInfo->bTrack && lpInfo->bInRect && bHasFocus) ); // Repair the dirty bitmap with the clean bitmap if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); } else { pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, NO /*bTransparent*/ ); } // Draw the slider background RECT rSlider = lpInfo->rSlider; RECT rInner = lpInfo->rSlider; rInner.top = lpInfo->iCenter - (lpInfo->iTrackWidth / 2); rInner.bottom = lpInfo->iCenter + (lpInfo->iTrackWidth / 2); MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rSlider, 2); MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rInner, 2); // Turn off tick painting because using background bitmap #ifdef UNUSED HBRUSH hBrush = CreateSolidBrush (lpInfo->rgbBackgnd); HBRUSH hBrush2 = (HBRUSH)GetStockObject (BLACK_BRUSH); FillRect (hWinGDC, & rSlider, hBrush); FillRect (hWinGDC, & rInner, hBrush2); DeleteObject (hBrush); #endif RECT rClient; GetClientRect (hWindow, & rClient); MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rClient, 2 ); // Turn off tick painting because using background bitmap #ifdef UNUSED // Draw a chiselled border RECT rBorder = rClient; InflateRect (& rBorder, 1, 1); int cxButton = rBorder.right - rBorder.left; int cyButton = rBorder.bottom - rBorder.top; HPEN hLitePen = CreatePen (PS_SOLID, 1, RGB (255, 255, 255)); HPEN hDarkPen = CreatePen (PS_SOLID, 1, RGB (128, 128, 128)); HPEN hOldPen = (HPEN)SelectObject (hWinGDC, hLitePen); MoveToEx (hWinGDC, rBorder.left, rBorder.bottom - 1, NULL); LineTo (hWinGDC, rBorder.left, rBorder.top); LineTo (hWinGDC, rBorder.right - 1, rBorder.top); MoveToEx (hWinGDC, rBorder.left + 1, rBorder.bottom - 2, NULL); LineTo (hWinGDC, rBorder.left + 1, rBorder.top + 1); LineTo (hWinGDC, rBorder.right - 2, rBorder.top + 1); SelectObject (hWinGDC, hDarkPen); MoveToEx (hWinGDC, rBorder.right - 1, rBorder.top, NULL); LineTo (hWinGDC, rBorder.right - 1, rBorder.bottom - 1); LineTo (hWinGDC, rBorder.left, rBorder.bottom - 1); MoveToEx (hWinGDC, rBorder.right - 2, rBorder.top + 1, NULL); LineTo (hWinGDC, rBorder.right - 2, rBorder.bottom - 2); LineTo (hWinGDC, rBorder.left + 1, rBorder.bottom - 2); SelectObject (hWinGDC, hOldPen); DeleteObject (hLitePen); DeleteObject (hDarkPen); // If tick-marks are wanted if (lpInfo->iTicks) { int pw = 2; // pen width HPEN hTickPen = CreatePen (PS_SOLID, pw, lpInfo->rgbBackgnd); hOldPen = (HPEN)SelectObject (hWinGDC, hTickPen); int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left; int wx = rClient.right - rClient.left - iBmpWidth; int dx = wx / lpInfo->iTicks; wx = wx - (dx * lpInfo->iTicks) - pw; int x = rClient.left + (iBmpWidth + wx + pw) / 2; // wx is now the excess int y1 = rClient.top + 2; int y2 = y1 + 10; for (int idx = 0; idx <= lpInfo->iTicks ; idx++) { MoveToEx (hWinGDC, x, y1, NULL); LineTo (hWinGDC, x, y2); x += dx; } SelectObject (hWinGDC, hOldPen); DeleteObject (hTickPen); } #endif rSrcArea = lpInfo->rBitmap; rDstArea = lpInfo->rBitmap; MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2 ); // Get the control ID to load the bitmap resource if (! (id = GetWindowWord (hWindow, GWW_ICONID) ) ) id = GET_WINDOW_ID (hWindow); if (pdibSrc = CDib::LoadDibFromResource (GetWindowInstance (hWindow), MAKEINTRESOURCE(id), GetApp()->m_hPal, (dwStyle & BS_MASK) != 0 )) { // Load the resource if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top ); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB( szColor, &rgb ); lpRGB = &rgb; } if (dwStyle & BS_HIGHLIGHT) { // Get the transparency color BYTE bTrans = *pdibSrc->GetXY(0, 0); // Get the color to replace LPTR lpColor = pdibSrc->GetXY(1, 0); BYTE bColor = *lpColor; *lpColor = bTrans; // Get the hightlight color LPTR lpHighlight = pdibSrc->GetXY(2, 0); BYTE bHighlight = *lpHighlight; *lpHighlight = bTrans; // Replace the pixels in the DIB if (bDown && (bColor != bHighlight)) { HPTR hp = pdibSrc->GetPtr(); DWORD dwSize = pdibSrc->GetSizeImage(); while ( dwSize-- ) { if (*hp == bColor) *hp = bHighlight; ++hp; } } } // Set slider position if needed if (lpInfo->Position) { int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left; int iWidth = rClient.right - rClient.left - iBmpWidth; int x = (int)(((long)(lpInfo->Position - lpInfo->Min) * iWidth) / (lpInfo->Max - lpInfo->Min)); rDstArea.left += x; if (rDstArea.left < rClient.left) rDstArea.left = rClient.left; else if (rDstArea.left + iBmpWidth > rClient.right) rDstArea.left = rClient.right - iBmpWidth; rDstArea.right = rDstArea.left + iBmpWidth; } pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, (dwStyle & BS_TRANSPARENT) != 0 /*bTransparent*/, lpRGB ); } delete pdibSrc; } ptDst.x = rSrcArea.left; ptDst.y = rSrcArea.top; if (lpScene) lpScene->Paint( hDC, &rClient, &ptDst ); }
long WINPROC EXPORT SpinControl( HWND hWindow, unsigned message, WPARAM wParam, LPARAM lParam) { int y; RECT ClientRect; PAINTSTRUCT ps; HDC hDC; BOOL bDown; DWORD dwStyle; long lReturn; static BOOL bTrack, bInTopRect, bInBottomRect; switch ( message ) { case WM_GETDLGCODE: return( DLGC_WANTARROWS ); case WM_ERASEBKGND: break; // handle ERASEBKGND and do nothing; PAINT covers everything case WM_PAINT: hDC = BeginPaint( hWindow, &ps ); GetClientRect( hWindow, &ClientRect ); y = ClientRect.bottom; ClientRect.bottom = 1 + ( ClientRect.top + ClientRect.bottom + 1 ) / 2; if ( ClientRect.bottom & 1 ) ClientRect.bottom++; // make sure its even bDown = bInTopRect && bTrack; DrawSpin( hDC, &ClientRect, 1, bDown ); ClientRect.top = ClientRect.bottom; ClientRect.bottom = y; bDown = bInBottomRect && bTrack; DrawSpin( hDC, &ClientRect, 0, bDown ); // dwStyle = GetWindowLong(GetDlgItem( GetParent(hWindow), // GET_WINDOW_ID(hWindow) ), GWL_STYLE); // if ( WS_NOTENABLED & dwStyle ) // GrayWindow( hDC, hWindow, -1L ); EndPaint( hWindow, &ps ); break; case WM_LBUTTONDOWN: dwStyle = GetWindowLong(GetDlgItem( GetParent(hWindow), GET_WINDOW_ID(hWindow) ), GWL_STYLE); if ( WS_NOTENABLED & dwStyle ) break; if ( bTrack ) break; SetCapture( hWindow ); bTrack = TRUE; SetFocus( GetDlgItem( GetParent(hWindow), GET_WINDOW_ID(hWindow) ) ); GetClientRect( hWindow, &ClientRect ); ClientRect.bottom = ( ClientRect.top + ClientRect.bottom + 1 ) / 2; bInTopRect = PtInRect( &ClientRect, MAKEPOINT(lParam) ); bInBottomRect = !bInTopRect; InvalidateRect( hWindow, NULL, FALSE ); UpdateWindow( hWindow ); SetTimer( hWindow, bTrack, 500, NULL ); break; case WM_LBUTTONUP: if ( !bTrack ) break; KillTimer( hWindow, bTrack ); ReleaseCapture(); bTrack = FALSE; InvalidateRect( hWindow, NULL, FALSE ); UpdateWindow( hWindow ); HandleSpinValue( hWindow, bInTopRect, bInBottomRect ); break; case WM_TIMER: if ( !bTrack ) break; KillTimer( hWindow, bTrack ); SetTimer( hWindow, bTrack, 100, NULL ); HandleSpinValue( hWindow, bInTopRect, bInBottomRect ); break; case WM_LBUTTONDBLCLK: break; case WM_MOUSEMOVE: if ( !bTrack ) break; GetClientRect( hWindow, &ClientRect ); y = ClientRect.bottom; ClientRect.bottom = ( ClientRect.top + ClientRect.bottom ) / 2; if ( bInTopRect == !PtInRect( &ClientRect, MAKEPOINT(lParam) ) ) { bInTopRect = !bInTopRect; InvalidateRect( hWindow, NULL, FALSE ); UpdateWindow( hWindow ); } ClientRect.top = ClientRect.bottom; ClientRect.bottom = y; if ( bInBottomRect == !PtInRect( &ClientRect, MAKEPOINT(lParam) ) ) { bInBottomRect = !bInBottomRect; InvalidateRect( hWindow, NULL, FALSE ); UpdateWindow( hWindow ); } break; case WM_ENABLE: case WM_SETTEXT: lReturn = DefWindowProc( hWindow, message, wParam, lParam ); InvalidateRect( hWindow, NULL, FALSE ); UpdateWindow(hWindow); return(lReturn); break; case WM_DESTROY: if ( !bTrack ) break; ReleaseCapture(); bTrack = NO; break; default: return( DefWindowProc( hWindow, message, wParam, lParam ) ); } return( TRUE ); }
LOCAL void Meter_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight) /***********************************************************************/ { RECT rSrcArea, rDstArea, rControlArea; POINT ptDst; PDIB pdibSrc, pdibDst, pdibSrc2, pdibTmp; UINT id; LPOFFSCREEN lpOffScreen; LPSCENE lpScene; HDC hWinGDC; HPALETTE hLoadPal; lpScene = CScene::GetScene( GetParent(hWindow) ); if (!lpScene) return; LPMETERCONTINFO lpInfo; if (!(lpInfo = (LPMETERCONTINFO)GetWindowLong(hWindow, GWL_DATAPTR) )) return; rSrcArea = * lpRect; rDstArea = * lpRect; rControlArea = * lpRect; lpOffScreen = lpScene->GetOffScreen(); if (lpOffScreen) { MapWindowPoints(hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2); if (!(pdibSrc = lpOffScreen->GetReadOnlyDIB() ) ) return; if (!(pdibDst = lpOffScreen->GetWritableDIB() ) ) return; hWinGDC = lpOffScreen->GetDC(); hLoadPal = GetApp()->m_hPal; } else { return; } RECT rClient; GetClientRect(hWindow, & rClient); MapWindowPoints(hWindow, GetParent(hWindow), (LPPOINT)& rClient, 2 ); // Get the control style DWORD dwStyle = GetWindowStyle(hWindow); BOOL bVert = (dwStyle & MC_VERT) ? TRUE : FALSE ; // Get the control id if (!(id = GetWindowWord(hWindow, GWW_ICONID) ) ) id = GET_WINDOW_ID(hWindow); // Refresh the background, // compressed DIBs must use GDI copying (lose transparency ability) if (pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8) { pdibSrc->DCBlt(hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); } else { pdibSrc->DibBlt(pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, NO /*bTransparent*/ ); } // Load the resource if (pdibSrc = CDib::LoadDibFromResource(GetWindowInstance(hWindow), MAKEINTRESOURCE(id), hLoadPal, (dwStyle & BS_MASK) != 0) ) { if (pdibSrc2 = CDib::LoadDibFromResource(GetWindowInstance(hWindow), MAKEINTRESOURCE(id + 1), hLoadPal, (dwStyle & BS_MASK) != 0) ) { int iBitmapWidth = pdibSrc->GetWidth(); int iBitmapHeight = pdibSrc->GetHeight(); rSrcArea.left = 0; rSrcArea.top = 0; rSrcArea.right = rSrcArea.left + iBitmapWidth; rSrcArea.bottom = rSrcArea.top + iBitmapHeight; rDstArea = rClient; rDstArea.right = rDstArea.left + iBitmapWidth; rDstArea.bottom = rDstArea.top + iBitmapHeight; // Get the position width int iPosWidth; if (bVert) { iPosWidth = (int)( (float)iBitmapHeight * ((float)lpInfo->lPosition / ((float)lpInfo->Max - (float)lpInfo->Min))); iPosWidth = iBitmapHeight - iPosWidth; } else { iPosWidth = (int)( (float)iBitmapWidth * ((float)lpInfo->lPosition / ((float)lpInfo->Max - (float)lpInfo->Min))); } // compressed DIBs must use GDI copying (lose transparency ability) if (pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { pdibSrc->DCBlt(hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB(szColor, & rgb); if (fHighlight) { // this relies on the fact that AsciiRGB replaces commas // with NULL terminators LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red lp += lstrlen(lp) + 1; // passed green lp += lstrlen(lp) + 1; // passed blue to higlight color AsciiRGB(lp, & rgb); } lpRGB = & rgb; } // Render the first bitmap pdibTmp = pdibSrc; pdibTmp->DibBlt(pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, FALSE /*bTransparent*/, lpRGB); } // Adjust the source and dest rect's and render the 2nd bitmap if (bVert) { //rDstArea.top = rDstArea.top;// iPosWidth; rDstArea.bottom = rDstArea.top + iPosWidth; //rSrcArea.top = rSrcArea.bottom - iPosWidth; rSrcArea.bottom = iPosWidth; } else { rDstArea.right = rDstArea.left + iPosWidth; rSrcArea.right = rSrcArea.left + iPosWidth; } // compressed DIBs must use GDI copying (lose transparency ability) if (pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { pdibSrc->DCBlt(hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top); } else { RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB(szColor, & rgb); if (fHighlight) { // this relies on the fact that AsciiRGB replaces commas // with NULL terminators LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red lp += lstrlen(lp) + 1; // passed green lp += lstrlen(lp) + 1; // passed blue to higlight color AsciiRGB(lp, & rgb); } lpRGB = & rgb; } // Render the first bitmap pdibTmp = pdibSrc2; pdibTmp->DibBlt(pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, FALSE /*bTransparent*/, lpRGB); } } delete pdibSrc; delete pdibSrc2; } ptDst.x = rControlArea.left; ptDst.y = rControlArea.top; if (lpOffScreen) { lpOffScreen->DrawRect(hDC, & rClient, & ptDst); } }
LOCAL void Bmulti_OnLButtonDblClk(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 1, SendMessage); }
void Video_GotoShot( HWND hWindow, LPVIDEO lpVideo, SHOTID lShot, long lCount, int iFrames, int iEventCode ) /***********************************************************************/ { LPSHOT lpShot; if ( !(lpShot = Video_GetShot( lpVideo, lShot, lCount )) ) { MCIStop( lpVideo->hDevice, YES/*bWait*/ ); MCIPlay( lpVideo->hDevice, hWindow/*Notify Myself*/ ); return; } if ( lpShot->wDisk != lpVideo->wDisk ) if ( !Video_Open( hWindow, lpVideo, lpShot->wDisk, lpShot->lStartFrame ) ) return; if ( lpShot->lShotID != lpVideo->lCurrentShot || !iEventCode ) { // if the shot is changing, or a NULL event code... // Send the notification message if the shot is changing lpShot->iLastEvent = iEventCode; LPPSHOT lppShot = &lpShot; FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), LOWORD(lppShot), HIWORD(lppShot), SendMessage ); if ( !(*lppShot) ) // if the application rejects this shot... return; // get out, and whatever is playing keeps playing // Set the previous shot variables, unless we could cause an infinite loop if ( lpShot->bGoesPrev ) { LPSHOT lpCurrentShot = Video_GetShotPtr( lpVideo, lpVideo->lCurrentShot ); if ( lpCurrentShot && !lpCurrentShot->bGoesPrev ) { lpVideo->lPrevFrame = MCIGetPosition( lpVideo->hDevice ); lpVideo->lPrevShot = lpVideo->lCurrentShot; } } lpVideo->lCurrentShot = lpShot->lShotID; } // Calculate the lFrom and lTo frames long lTo = lpShot->lEndFrame; long lFrom = lpShot->lStartFrame; if ( iFrames > 0 ) lFrom = max( lTo - iFrames, lFrom ); if ( lpShot->lIndentFrames ) { // If indention is being used... lFrom += lpShot->lIndentFrames; lpShot->lIndentFrames = 0; if ( lFrom > lTo ) lFrom = lTo; } else // Clear any disabled hotspot flags Video_ShotEnableHotspots( lpVideo, lpShot ); MCIStop( lpVideo->hDevice, YES/*bWait*/ ); MCIPlay( lpVideo->hDevice, hWindow/*Notify Myself*/, lFrom, lTo ); lpVideo->lLastShotToPlay = lpVideo->lCurrentShot; }
static void Video_ProcessEvent( HWND hWindow, LPVIDEO lpVideo, int iEventCode, int iEventToPassAlong = 0 ) /***********************************************************************/ { // Check to see what the video action should be, based on the event code SHOTID lShot, lTimerShot; long lCount, lTimerCount; int iFrames, iSeconds; LPSHOT lpShot; if ( !(lpShot = Video_GetShotPtr( lpVideo, lpVideo->lCurrentShot )) ) return; iFrames = 0; iSeconds = 0; switch ( iEventCode ) { case EVENT_END: // the "END" event if ( !lpShot->lEndLoop ) { lShot = lpShot->lEndShot; lCount = lpShot->lEndCount; } else { // (LOWORD(lLoop) = number of seconds to loop; 0 == forever) // (HIWORD(lLoop) = number of frames to loop; 0 == all frames) iFrames = HIWORD(lpShot->lEndLoop); if ( iSeconds = LOWORD(lpShot->lEndLoop) ) { lTimerShot = lpShot->lEndShot; lTimerCount = lpShot->lEndCount; } lShot = lpShot->lShotID; lCount = 1; } break; case EVENT_LEFT: // the "LEFT" event if ( lpShot->bLeftIsSubShot ) { if ( !(lpShot = Video_FindSubShot( lpVideo, lpShot->lLeftShot, lpShot->lLeftCount, 0 )) ) return; } lShot = lpShot->lLeftShot; lCount = lpShot->lLeftCount; break; case EVENT_UP: // the "UP" event if ( lpShot->bUpIsSubShot ) { if ( !(lpShot = Video_FindSubShot( lpVideo, lpShot->lUpShot, lpShot->lUpCount, 0 )) ) return; } lShot = lpShot->lUpShot; lCount = lpShot->lUpCount; break; case EVENT_RIGHT: // the "RIGHT" event if ( lpShot->bRightIsSubShot ) { if ( !(lpShot = Video_FindSubShot( lpVideo, lpShot->lRightShot, lpShot->lRightCount, 0 )) ) return; } lShot = lpShot->lRightShot; lCount = lpShot->lRightCount; break; case EVENT_DOWN: // the "DOWN" event if ( lpShot->bDownIsSubShot ) { if ( !(lpShot = Video_FindSubShot( lpVideo, lpShot->lDownShot, lpShot->lDownCount, 0 )) ) return; } lShot = lpShot->lDownShot; lCount = lpShot->lDownCount; break; case EVENT_HOME: // the "HOME" event if ( lpShot->bHomeIsSubShot ) { if ( !(lpShot = Video_FindSubShot( lpVideo, lpShot->lHomeShot, lpShot->lHomeCount, 0 )) ) return; } lShot = lpShot->lHomeShot; lCount = lpShot->lHomeCount; break; default: return; } if ( !lShot ) { MessageBeep(0); return; } if ( iEventToPassAlong ) iEventCode = iEventToPassAlong; if (lShot == SHOT_STOP) // send a NULL for lppShot to indicate stop FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), 0, 0, SendMessage ); else Video_GotoShot( hWindow, lpVideo, lShot, lCount, iFrames, iEventCode ); if ( iSeconds ) // if a timer (in seconds) is specified... Video_SetJumpTimer( hWindow, iSeconds, lTimerShot, lTimerCount ); }
LOCAL void Bmulti_Paint(HWND hWindow, HDC hDC, LPRECT lpRect) /***********************************************************************/ { BOOL bHasFocus, bSelected, bDown; DWORD dwStyle; RECT rSrcArea, rDstArea; POINT ptDst; PDIB pdibSrc, pdibDst; UINT id; HDC hWinGDC; HPALETTE hLoadPal; BOOL fUseScene = TRUE; LPBMULTICONTINFO lpInfo; if (! (lpInfo = (LPBMULTICONTINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) ) return; rSrcArea = *lpRect; rDstArea = *lpRect; LPSCENE lpScene = CScene::GetScene(GetParent(hWindow)); if ( !lpScene ) return; if ( lpScene->GetDIBs( &pdibSrc, &pdibDst, &hWinGDC ) ) { if ( !pdibDst ) return; hLoadPal = GetApp()->m_hPal; MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 ); } else return; bSelected = GetWindowWord (hWindow, GWW_STATE); dwStyle = GetWindowLong (hWindow, GWL_STYLE); bHasFocus = (GetFocus() == hWindow); bDown = ( bSelected || (lpInfo->bTrack && lpInfo->bInRect && bHasFocus) ); // Draw the Bitmap if ( !(id = GetWindowWord( hWindow, GWW_ICONID )) ) id = GET_WINDOW_ID( hWindow ); id += lpInfo->State; // Repair the dirty bitmap with the clean bitmap if ( pdibSrc && pdibDst ) { if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top ); } else { pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, NO /*bTransparent*/ ); } } if (pdibSrc = CDib::LoadDibFromResource( GetWindowInstance(hWindow), MAKEINTRESOURCE(id), hLoadPal, (dwStyle & BS_MASK) != 0 ) ) { // Load the resource // Do highlighting andf transparency RGBTRIPLE rgb; LPRGBTRIPLE lpRGB = NULL; if (dwStyle & BS_MASK) { STRING szColor; GetWindowText(hWindow, szColor, sizeof(szColor)); AsciiRGB( szColor, &rgb ); lpRGB = &rgb; } if (dwStyle & BS_HIGHLIGHT) { // Get the transparency color BYTE bTrans = *pdibSrc->GetXY(0, 0); // Get the color to replace LPTR lpColor = pdibSrc->GetXY(1, 0); BYTE bColor = *lpColor; *lpColor = bTrans; // Get the hightlight color LPTR lpHighlight = pdibSrc->GetXY(2, 0); BYTE bHighlight = *lpHighlight; *lpHighlight = bTrans; // Replace the pixels in the DIB if (bDown && (bColor != bHighlight)) { HPTR hp = pdibSrc->GetPtr(); DWORD dwSize = pdibSrc->GetSizeImage(); while ( dwSize-- ) { if (*hp == bColor) *hp = bHighlight; ++hp; } } } if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 ) { // compressed DIBs must use GDI copying (lose transparency ability) pdibSrc->DCBlt( hWinGDC, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top ); } else { pdibSrc->DibBlt( pdibDst, rDstArea.left, rDstArea.top, rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top, rSrcArea.left, rSrcArea.top, rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top, (dwStyle & BS_TRANSPARENT) != 0 /*bTransparent*/, lpRGB ); } delete pdibSrc; } ptDst.x = rSrcArea.left; ptDst.y = rSrcArea.top; if (fUseScene) lpScene->Paint( hDC, &rDstArea, &ptDst ); }