00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "ChildView.h"
00028 #include "MainFrm.h"
00029
00030 #ifdef _DEBUG
00031 #define new DEBUG_NEW
00032 #undef THIS_FILE
00033 static char THIS_FILE[] = __FILE__;
00034 #endif
00035
00037
00038
00039 CChildView::CChildView() : m_vrect(0,0,0,0)
00040 {
00041 m_lastlmdowntime = 0;
00042 m_lastlmdownpoint.SetPoint(0, 0);
00043
00044 LoadLogo();
00045 }
00046
00047 CChildView::~CChildView()
00048 {
00049 }
00050
00051 BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
00052 {
00053 if(!CWnd::PreCreateWindow(cs))
00054 return FALSE;
00055
00056 cs.style &= ~WS_BORDER;
00057 cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
00058 ::LoadCursor(NULL, IDC_HAND), HBRUSH(COLOR_WINDOW+1), NULL);
00059
00060 return TRUE;
00061 }
00062
00063 BOOL CChildView::PreTranslateMessage(MSG* pMsg)
00064 {
00065 if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST)
00066 {
00067 CWnd* pParent = GetParent();
00068 CPoint p(pMsg->lParam);
00069 ::MapWindowPoints(pMsg->hwnd, pParent->m_hWnd, &p, 1);
00070
00071 bool fDblClick = false;
00072
00073 bool fInteractiveVideo = ((CMainFrame*)AfxGetMainWnd())->IsInteractiveVideo();
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 if((pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONUP || pMsg->message == WM_MOUSEMOVE)
00101 && fInteractiveVideo)
00102 {
00103 if(pMsg->message == WM_MOUSEMOVE)
00104 {
00105 pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
00106 }
00107
00108 if(fDblClick)
00109 {
00110 pParent->PostMessage(WM_LBUTTONDOWN, pMsg->wParam, MAKELPARAM(p.x, p.y));
00111 pParent->PostMessage(WM_LBUTTONDBLCLK, pMsg->wParam, MAKELPARAM(p.x, p.y));
00112 }
00113 }
00114 else
00115 {
00116 pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
00117 return TRUE;
00118 }
00119 }
00120
00121 return CWnd::PreTranslateMessage(pMsg);
00122 }
00123
00124 void CChildView::SetVideoRect(CRect r)
00125 {
00126 m_vrect = r;
00127
00128 Invalidate();
00129 }
00130
00131 void CChildView::LoadLogo()
00132 {
00133 AppSettings& s = AfxGetAppSettings();
00134
00135 CAutoLock cAutoLock(&m_csLogo);
00136
00137 m_logo.Destroy();
00138
00139 if(s.logoext)
00140 {
00141 if(AfxGetAppSettings().fXpOrBetter)
00142 m_logo.Load(s.logofn);
00143 else if(HANDLE h = LoadImage(NULL, s.logofn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
00144 m_logo.Attach((HBITMAP)h);
00145 }
00146
00147 if(m_logo.IsNull())
00148 {
00149 m_logo.LoadFromResource(AfxGetInstanceHandle(), s.logoid);
00150 }
00151
00152 if(m_hWnd) Invalidate();
00153 }
00154
00155 CSize CChildView::GetLogoSize()
00156 {
00157 CSize ret(0,0);
00158 if(!m_logo.IsNull())
00159 ret.SetSize(m_logo.GetWidth(), m_logo.GetHeight());
00160 return ret;
00161 }
00162
00163 IMPLEMENT_DYNAMIC(CChildView, CWnd)
00164
00165 BEGIN_MESSAGE_MAP(CChildView, CWnd)
00166
00167 ON_WM_PAINT()
00168 ON_WM_ERASEBKGND()
00169 ON_WM_SIZE()
00170 ON_WM_WINDOWPOSCHANGED()
00171 ON_COMMAND_EX(ID_PLAY_PLAYPAUSE, OnPlayPlayPauseStop)
00172 ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlayPauseStop)
00173 ON_COMMAND_EX(ID_PLAY_PAUSE, OnPlayPlayPauseStop)
00174 ON_COMMAND_EX(ID_PLAY_STOP, OnPlayPlayPauseStop)
00175 ON_WM_SETCURSOR()
00176 ON_WM_NCCALCSIZE()
00177 ON_WM_NCPAINT()
00178
00179 END_MESSAGE_MAP()
00180
00181
00182
00183
00184
00185 void CChildView::OnPaint()
00186 {
00187 CPaintDC dc(this);
00188
00189 ((CMainFrame*)GetParentFrame())->RepaintVideo();
00190
00191
00192 }
00193
00194 BOOL CChildView::OnEraseBkgnd(CDC* pDC)
00195 {
00196 CRect r;
00197
00198 CAutoLock cAutoLock(&m_csLogo);
00199
00200 if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded())
00201 {
00202 pDC->ExcludeClipRect(m_vrect);
00203 }
00204 else if(!m_logo.IsNull() )
00205 {
00206 BITMAP bm;
00207 GetObject(m_logo, sizeof(bm), &bm);
00208
00209 GetClientRect(r);
00210 int w = min(bm.bmWidth, r.Width());
00211 int h = min(abs(bm.bmHeight), r.Height());
00212
00213
00214 int x = (r.Width() - w) / 2;
00215 int y = (r.Height() - h) / 2;
00216 r = CRect(CPoint(x, y), CSize(w, h));
00217
00218 int oldmode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
00219 m_logo.StretchBlt(*pDC, r, CRect(0,0,bm.bmWidth,abs(bm.bmHeight)));
00220
00221 pDC->SetStretchBltMode(oldmode);
00222
00223 pDC->ExcludeClipRect(r);
00224 }
00225
00226 GetClientRect(r);
00227 pDC->FillSolidRect(r, 0);
00228
00229 return TRUE;
00230 }
00231
00232 void CChildView::OnSize(UINT nType, int cx, int cy)
00233 {
00234 CWnd::OnSize(nType, cx, cy);
00235
00236 ((CMainFrame*)GetParentFrame())->MoveVideoWindow();
00237 }
00238
00239 void CChildView::OnWindowPosChanged(WINDOWPOS* lpwndpos)
00240 {
00241 CWnd::OnWindowPosChanged(lpwndpos);
00242
00243 ((CMainFrame*)GetParentFrame())->MoveVideoWindow();
00244 }
00245
00246 BOOL CChildView::OnPlayPlayPauseStop(UINT nID)
00247 {
00248 if(nID == ID_PLAY_STOP) SetVideoRect();
00249 return FALSE;
00250 }
00251
00252 BOOL CChildView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00253 {
00254 if(((CMainFrame*)GetParentFrame())->m_fHideCursor)
00255 {
00256 SetCursor(NULL);
00257 return TRUE;
00258 }
00259
00260 return CWnd::OnSetCursor(pWnd, nHitTest, message);
00261 }
00262
00263 void CChildView::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
00264 {
00265 if(!((CMainFrame*)GetParentFrame())->IsFrameLessWindow())
00266 {
00267 InflateRect(&lpncsp->rgrc[0], -1, -1);
00268 }
00269
00270 CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
00271 }
00272
00273 void CChildView::OnNcPaint()
00274 {
00275 if(!((CMainFrame*)GetParentFrame())->IsFrameLessWindow())
00276 {
00277 CRect r;
00278 GetWindowRect(r);
00279 r.OffsetRect(-r.left, -r.top);
00280
00281 CWindowDC(this).Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
00282 }
00283 }
00284