📄 playerwindow.cpp
字号:
TEXT("Shuffle"), NULL,
&dwType, (BYTE*)&m_bShuffle,
&dwSize);
dwSize = sizeof (m_dwZoomLevel);
RegQueryValueEx(hkResult,
TEXT("ZoomLevel"), NULL,
&dwType, (BYTE*)&m_dwZoomLevel,
&dwSize);
dwSize = sizeof (dwTemp);
RegQueryValueEx(hkResult,
TEXT("Muted"), NULL,
&dwType, (BYTE*)&dwTemp,
&dwSize);
if( m_pMP )
{
fMuted = (VARIANT_BOOL)dwTemp;
m_pMP->put_Mute(fMuted);
}
dwSize = sizeof (lVolume);
if (ERROR_SUCCESS == RegQueryValueEx(hkResult,
TEXT("Volume"), NULL,
&dwType, (BYTE*)&lVolume,
&dwSize)
&& sizeof (LONG) == dwSize
&& NULL != m_pMP)
{
m_pMP->put_Volume(VolumeLinToLog((short)lVolume));
}
else if (NULL != m_pMP)
{
// If a value couldn't be found in the registry, use a
// reasonable default value.
m_pMP->put_Volume(AX_HALF_VOLUME);
}
}
RegCloseKey(hkResult);
bResult = true;
ApplyPlayCount();
ApplyZoomLevel();
}
return bResult;
}
///////////////////////////////////////////////////////////////////////////////
// Name: CPlayerWindow::OnCommand()
// Desc: This function is used then a WM_COMMAND message is received by the
// main WinProc. It will figure out which function or action to take
// based on the type of command received.
///////////////////////////////////////////////////////////////////////////////
bool CPlayerWindow::OnCommand(WORD wID, LPARAM lParam)
{
bool bResult = false;
if (ID_FAVORITE_MIN <= wID && wID <= ID_FAVORITE_MAX)
{
return OnFavorite((int)wID - ID_FAVORITE_MIN);
}
switch (wID)
{
case ID_FILE_OPEN_URL:
bResult = OnOpenURL();
break;
case ID_FILE_CLOSE:
bResult = OnClose();
break;
case ID_FILE_PLAYLISTS:
bResult = OnPlaylist();
break;
case ID_ADD_TO_FAVORITES:
bResult = OnAddToFavorites();
break;
case ID_ORGANIZE_FAVORITES:
bResult = OnOrganizeFavorites();
break;
case ID_FILE_EXIT:
::PostMessage(m_hWnd, WM_CLOSE, NULL, NULL);
bResult = true;
break;
#ifndef CEPLAYER_SKIN
case ID_VIEW_STANDARD:
m_dwLevelOfControls = 2;
UpdateMenus();
UpdateDisplay();
bResult = true;
break;
case ID_VIEW_MINIMAL:
m_dwLevelOfControls = 0;
UpdateMenus();
UpdateDisplay();
bResult = true;
break;
#endif /* CEPLAYER_SKIN */
case ID_VIEW_ZOOM_50:
m_dwZoomLevel = 0;
ApplyZoomLevel();
bResult = true;
break;
case ID_VIEW_ZOOM_100:
m_dwZoomLevel = 1;
ApplyZoomLevel();
bResult = true;
break;
case ID_VIEW_ZOOM_200:
m_dwZoomLevel = 2;
ApplyZoomLevel();
bResult = true;
break;
case ID_VIEW_FULLSCREEN:
bResult = OnFullScreen();
break;
case ID_VIEW_STATISTICS:
bResult = OnStatistics();
break;
case ID_VIEW_PROPERTIES:
bResult = OnProperties();
break;
case ID_VIEW_OPTIONS:
bResult = OnOptions();
break;
case ID_PLAYBACK_PLAY:
bResult = OnPlay();
break;
case ID_PLAYBACK_PAUSE:
bResult = OnPause();
break;
case ID_PLAYBACK_STOP:
bResult = OnStop();
break;
case ID_PLAYBACK_MUTE:
bResult = OnMute();
break;
case ID_PLAYBACK_REPEAT:
bResult = OnRepeat();
break;
case ID_PLAYBACK_SHUFFLE:
bResult = OnShuffle();
break;
case ID_PLAY_SONG:
if (NULL != (CPlaylist*)lParam)
{
((CPlaylist*)lParam)->ResetPlayed();
}
bResult = OnPlaySong((CPlaylist*)lParam);
break;
case ID_GOWEB:
bResult = OnGoWeb();
break;
case ID_PLAYLIST_NEXT:
OnStop();
EndOfStream(0);
break;
}
return bResult;
}
///////////////////////////////////////////////////////////////////////////////
// Name: CPlayerWindow::OnWindowMessage()
// Desc: This function is called if a message is received by the main WinProc
// and no other function has handled the message. Essentially it allows
// the MediaPlayer control to respond to mouse events.
///////////////////////////////////////////////////////////////////////////////
bool CPlayerWindow::OnWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lr = 0;
bool bResult = false;
// Forward any window messages to the control so that the control can
// take appropriate action.
if (NULL != m_pIPOW)
{
if (SUCCEEDED(m_pIPOW->OnWindowMessage(uMsg, wParam, lParam, &lr)))
{
bResult = true;
}
}
return bResult;
}
///////////////////////////////////////////////////////////////////////////////
// Name: CPlayerWindow::OnPaint()
// Desc: This function is called when a WM_PAINT message is received. It
// just hands the message to the MPContainer class.
///////////////////////////////////////////////////////////////////////////////
void CPlayerWindow::OnPaint(HDC hdc, RECT *prc)
{
#ifdef CEPLAYER_SKIN
RECT rc;
LONG lVolume = 0;
VARIANT_BOOL fHasMultipleItems = VARIANT_FALSE;
GetClientRect(m_hWnd, &rc);
if (NULL == m_pMP)
{
FillRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
return;
}
m_pMP->get_Volume(&lVolume);
lVolume = VolumeLogToLin(lVolume);
m_pMP->get_HasMultipleItems(&fHasMultipleItems);
if (prc->bottom == rc.bottom)
{
prc->bottom -= SKIN_HEIGHT;
}
if (NULL == m_hbmBuffer)
{
m_hbmBuffer = CreateCompatibleBitmap(hdc, SKIN_WIDTH, SKIN_HEIGHT);
}
#endif /* CEPLAYER_SKIN */
CMPContainer::Paint(hdc, prc);
#ifdef CEPLAYER_SKIN
//
// draw in the last 40 pixels of the window
//
COLORREF cTransColor = RGB(255, 0, 255);
COLORREF cBkColor = RGB(100, 125, 192);
HBRUSH hbrush;
HDC hdcBuf;
RECT rcFill;
int x,y;
// Center the controls
x = rc.left + (rc.right - rc.left - SKIN_WIDTH)/2;
y = rc.bottom - SKIN_HEIGHT + 2;
m_iSkinMargin = x - rc.left;
hdcBuf = CreateCompatibleDC(hdc);
SelectObject(hdcBuf, m_hbmBuffer);
//
// Fill in the back buffer
//
rcFill.left = 0;
rcFill.right = SKIN_WIDTH;
rcFill.top = 0;
rcFill.bottom = SKIN_HEIGHT;
hbrush = CreateSolidBrush(cBkColor);
FillRect(hdcBuf, &rcFill, hbrush);
DeleteObject(hbrush);
for (int i = 0; i < SKIN_SIZE; i++)
{
HBITMAP hbitmap = NULL;
HDC hdcBmp = NULL;
// Only draw either the play button, or the pause button. Never both
if (m_bPlayPause && SKIN_PAUSE == i) continue;
if (!m_bPlayPause && SKIN_PLAY == i) continue;
EnterCriticalSection( &m_csButtonInfoCritSec );
if (UP == m_binfo[i].eState)
{
hbitmap = m_binfo[i].hUp;
}
else if (DOWN == m_binfo[i].eState)
{
hbitmap = m_binfo[i].hDown;
if (SKIN_VOLUME == i || SKIN_SEEK == i)
{
hbitmap = m_binfo[i].hUp;
}
}
else if (DISABLED == m_binfo[i].eState)
{
if (SKIN_PAUSE == i)
{
#ifdef UNDER_CE
ASSERT(0);
#endif /* UNDER_CE */
}
else
{
hbitmap = m_binfo[i].hDisabled;
}
}
else
{
DebugBreak();
}
m_binfo[i].rc.left = x + m_binfo[i].ptPos.x;
m_binfo[i].rc.right = m_binfo[i].rc.left + m_binfo[i].ptDim.x;
m_binfo[i].rc.top = y + m_binfo[i].ptPos.y;
m_binfo[i].rc.bottom = m_binfo[i].rc.top + m_binfo[i].ptDim.y;
hdcBmp = CreateCompatibleDC(hdc);
SelectObject(hdcBmp, hbitmap);
BitBlt(hdcBuf,
m_binfo[i].rc.left - x,
m_binfo[i].rc.top - y,
m_binfo[i].ptDim.x,
m_binfo[i].ptDim.y,
hdcBmp,
0,
0,
SRCCOPY);
LeaveCriticalSection( &m_csButtonInfoCritSec );
DeleteDC(hdcBmp);
}
// Let's add the speed if we're fast forwarding or fast rewarding.
if( ratesArray[ m_currentRate ] != 1 )
{
WCHAR wzBuffer[10];
COLORREF oldTextColor, oldBgColor;
RECT rcText = { 0 };
SIZE textSize = { 0 };
wsprintf( wzBuffer, L"x%d", ratesArray[ m_currentRate ] );
GetTextExtentPoint( hdcBuf, wzBuffer, wcslen( wzBuffer ), &textSize );
rcText.left = m_rcSeekBounds.right + 10;
rcText.right = rcText.left + textSize.cx;
rcText.top = m_rcSeekBounds.top;
rcText.bottom = rcText.top + textSize.cy;
oldBgColor = SetBkColor( hdcBuf, cBkColor );
oldTextColor = SetTextColor( hdcBuf, RGB( 0, 0, 0 ));
DrawText( hdcBuf, wzBuffer, wcslen( wzBuffer ), &rcText, DT_LEFT );
SetBkColor( hdcBuf, oldBgColor );
SetTextColor( hdcBuf, oldTextColor );
}
//
// Draw the Seek Slider Thumb
//
if (m_fCanSeek)
{
HBITMAP hbitmap = NULL;
if (UP == m_binfoSeekThumb.eState)
{
hbitmap = m_binfoSeekThumb.hUp;
}
else
{
hbitmap = m_binfoSeekThumb.hDown;
}
m_binfoSeekThumb.rc.left = x + m_binfoSeekThumb.ptPos.x;
m_binfoSeekThumb.rc.right = m_binfoSeekThumb.rc.left + m_binfoSeekThumb.ptDim.x;
m_binfoSeekThumb.rc.top = y + m_binfoSeekThumb.ptPos.y;
m_binfoSeekThumb.rc.bottom = m_binfoSeekThumb.rc.top + m_binfoSeekThumb.ptDim.y;
TransparentImage(hdcBuf,
m_binfoSeekThumb.rc.left - x,
m_binfoSeekThumb.rc.top - y,
m_binfoSeekThumb.ptDim.x,
m_binfoSeekThumb.ptDim.y,
hbitmap,
0, 0,
m_binfoSeekThumb.ptDim.x,
m_binfoSeekThumb.ptDim.y,
cTransColor);
}
//
// Draw the Volume Slider Thumb
//
if (DISABLED != m_binfo[SKIN_VOLUME].eState)
{
HBITMAP hbitmap = NULL;
if (UP == m_binfoVolThumb.eState)
{
hbitmap = m_binfoVolThumb.hUp;
}
else
{
hbitmap = m_binfoVolThumb.hDown;
}
if (UP == m_binfoVolThumb.eState)
{
if (MIN_VOLUME_RANGE < lVolume && lVolume < MAX_VOLUME_RANGE)
{
lVolume = (m_rcVolBounds.right - m_rcVolBounds.left) * lVolume / (MAX_VOLUME_RANGE - MIN_VOLUME_RANGE);
}
else if (MAX_VOLUME_RANGE == lVolume)
{
lVolume = m_rcVolBounds.right - m_rcVolBounds.left;
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -