1 // LyricsWindow.cpp : 实现文件 2 // 3 4 #include "stdafx.h" 5 #include "LyricsWindow.h" 6 7 // CLyricsWindow 8 9 const Gdiplus::REAL TRANSLATE_FONT_SIZE_FACTOR = 0.88f; //歌词翻译文本大小占歌词文本大小的比例 10 11 IMPLEMENT_DYNAMIC(CLyricsWindow, CWnd) 12 13 CLyricsWindow::CLyricsWindow() 14 { 15 HDC hDC=::GetDC(NULL); 16 m_hCacheDC=::CreateCompatibleDC(hDC); 17 ::ReleaseDC(NULL,hDC); 18 //--------------------------------- 19 m_nHighlight=NULL ; //高亮歌词的百分比 0--100 20 m_TextGradientMode=LyricsGradientMode_Two ; //普通歌词渐变模式 21 m_pTextPen=NULL ; //普通歌词边框画笔 22 m_HighlightGradientMode=LyricsGradientMode_Two ; //高亮歌词渐变模式 23 m_pHighlightPen=NULL ; //高亮歌词边框画笔 24 m_pShadowBrush=NULL ; //阴影画刷,GDIPlus画刷 25 m_nShadowOffset=1 ; //阴影偏移 26 m_pFont=NULL ; //GDIPlus字体 27 m_FontStyle=NULL ; 28 m_FontSize=NULL ; 29 m_pTextFormat=NULL; 30 //--------------------------------- 31 m_pFontFamily=new Gdiplus::FontFamily(); 32 m_pTextFormat=new Gdiplus::StringFormat(); 33 m_pTextFormat->SetFormatFlags(Gdiplus::StringFormatFlagsNoWrap);//不换行 34 m_pTextFormat->SetAlignment(Gdiplus::StringAlignmentCenter); //置水平对齐方式 35 m_pTextFormat->SetLineAlignment(Gdiplus::StringAlignmentNear); //置垂直对齐方式 36 //--------------------------------- 37 //SetLyricsFont(L"微软雅黑", 40, Gdiplus::FontStyle::FontStyleRegular); 38 //SetLyricsColor(Gdiplus::Color::Red,Gdiplus::Color(255,172,0),LyricsGradientMode_Three); 39 //SetLyricsBorder(Gdiplus::Color::Black,1); 40 SetLyricsShadow(Gdiplus::Color(150,0,0,0),1); 41 //SetHighlightColor(Gdiplus::Color(255,100,26),Gdiplus::Color(255,255,0),LyricsGradientMode_Three); 42 //SetHighlightBorder(Gdiplus::Color::Black,1); 43 44 } 45 46 CLyricsWindow::~CLyricsWindow() 47 { 48 if(m_pTextPen){ 49 delete m_pTextPen; 50 m_pTextPen=NULL; 51 } 52 if(m_pHighlightPen){ 53 delete m_pHighlightPen; 54 m_pHighlightPen=NULL; 55 } 56 if(m_pShadowBrush){ 57 delete m_pShadowBrush; 58 m_pShadowBrush=NULL; 59 } 60 if(m_pFontFamily){ 61 delete m_pFontFamily; 62 m_pFontFamily=NULL; 63 } 64 if(m_pTextFormat){ 65 delete m_pTextFormat; 66 m_pTextFormat=NULL; 67 } 68 if(m_pFont){ 69 delete m_pFont; 70 m_pFont=NULL; 71 } 72 } 73 74 75 BEGIN_MESSAGE_MAP(CLyricsWindow, CWnd) 76 ON_WM_LBUTTONDOWN() 77 END_MESSAGE_MAP() 78 79 80 81 BOOL CLyricsWindow::Create(int nHeight) 82 { 83 return CLyricsWindow::Create(_T("CometLyricsWindow"), -1, nHeight); 84 } 85 BOOL CLyricsWindow::Create(LPCTSTR lpszClassName) 86 { 87 return CLyricsWindow::Create(lpszClassName,-1,-1); 88 } 89 BOOL CLyricsWindow::Create(LPCTSTR lpszClassName,int nWidth,int nHeight) 90 { 91 if(!RegisterWndClass(lpszClassName)) 92 { 93 TRACE("Class Registration Failedn"); 94 } 95 96 //-------------------------------------------- 97 //取出桌面工作区域 98 RECT rcWork; 99 SystemParametersInfo (SPI_GETWORKAREA,NULL,&rcWork,NULL); 100 int nWorkWidth=rcWork.right-rcWork.left; 101 int nWorkHeight=rcWork.bottom-rcWork.top; 102 //未传递宽度、高度参数时设置个默认值 103 if(nWidth<0)nWidth=nWorkWidth*2/3; //默认宽度为桌面宽度的2/3 104 if(nHeight<0)nHeight=150; 105 //设置左边、顶边位置,让窗口在屏幕下方 106 int x=rcWork.left+( (nWorkWidth-nWidth)/2 ); 107 int y=rcWork.bottom-nHeight; 108 //-------------------------------------------- 109 DWORD dwStyle=WS_POPUP|WS_VISIBLE|WS_THICKFRAME; 110 DWORD dwExStyle=WS_EX_TOOLWINDOW|WS_EX_TOPMOST|WS_EX_LAYERED; 111 BOOL rtn = CWnd::CreateEx(dwExStyle, lpszClassName, NULL, dwStyle, x, y, nWidth, nHeight, NULL, NULL); 112 113 return rtn; 114 } 115 BOOL CLyricsWindow::RegisterWndClass(LPCTSTR lpszClassName) 116 { 117 HINSTANCE hInstance=AfxGetInstanceHandle(); 118 WNDCLASSEX wndcls; 119 memset(&wndcls,0,sizeof(WNDCLASSEX)); 120 wndcls.cbSize=sizeof(WNDCLASSEX); 121 if(GetClassInfoEx(hInstance,lpszClassName,&wndcls)) 122 { 123 return TRUE; 124 } 125 if(GetClassInfoEx(NULL,lpszClassName,&wndcls)) 126 { 127 return TRUE; 128 } 129 130 wndcls.style=CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; 131 wndcls.lpfnWndProc=::DefWindowProc; 132 wndcls.hInstance=hInstance; 133 wndcls.hIcon=NULL; 134 wndcls.hCursor=::LoadCursor(NULL,IDC_ARROW); 135 wndcls.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1); 136 wndcls.lpszMenuName=NULL; 137 wndcls.lpszClassName=lpszClassName; 138 if(!RegisterClassEx(&wndcls)) 139 { 140 return FALSE; 141 } 142 return TRUE; 143 } 144 145 146 //更新歌词(歌词文本,高亮进度百分比) 147 void CLyricsWindow::UpdateLyrics(LPCTSTR lpszLyrics,int nHighlight) 148 { 149 m_lpszLyrics = lpszLyrics; 150 UpdateLyrics(nHighlight); 151 } 152 //更新高亮进度(高亮进度百分比) 153 void CLyricsWindow::UpdateLyrics(int nHighlight) 154 { 155 m_nHighlight=nHighlight; 156 if(m_nHighlight<0) 157 m_nHighlight=0; 158 if(m_nHighlight>1000) 159 m_nHighlight=1000; 160 Draw(); 161 } 162 163 void CLyricsWindow::UpdateLyricTranslate(LPCTSTR lpszLyricTranslate) 164 { 165 m_strTranslate = lpszLyricTranslate; 166 } 167 168 //重画歌词窗口 169 void CLyricsWindow::Draw() 170 { 171 //CRect rcWindow; 172 GetWindowRect(m_rcWindow); 173 m_nWidth= m_rcWindow.Width(); 174 m_nHeight= m_rcWindow.Height(); 175 CRect rcClient; 176 GetClientRect(rcClient); 177 m_frameSize.cx = (m_rcWindow.Width() - rcClient.Width()) / 2; 178 m_frameSize.cy = (m_rcWindow.Height() - rcClient.Height()) / 2; 179 180 //---------------------------------- 181 BITMAPINFO bitmapinfo; 182 bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 183 bitmapinfo.bmiHeader.biBitCount = 32; 184 bitmapinfo.bmiHeader.biHeight = m_nHeight; 185 bitmapinfo.bmiHeader.biWidth = m_nWidth; 186 bitmapinfo.bmiHeader.biPlanes = 1; 187 bitmapinfo.bmiHeader.biCompression=BI_RGB; 188 bitmapinfo.bmiHeader.biXPelsPerMeter=0; 189 bitmapinfo.bmiHeader.biYPelsPerMeter=0; 190 bitmapinfo.bmiHeader.biClrUsed=0; 191 bitmapinfo.bmiHeader.biClrImportant=0; 192 bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth * bitmapinfo.bmiHeader.biHeight * bitmapinfo.bmiHeader.biBitCount / 8; 193 HBITMAP hBitmap=CreateDIBSection (m_hCacheDC,&bitmapinfo, 0,NULL, 0, 0); 194 HBITMAP hOldBitmap = (HBITMAP)SelectObject (m_hCacheDC,hBitmap); 195 //---------------------------------- 196 Gdiplus::Graphics* pGraphics=new Gdiplus::Graphics(m_hCacheDC); 197 pGraphics->SetSmoothingMode (Gdiplus::SmoothingModeAntiAlias); 198 pGraphics->SetTextRenderingHint (Gdiplus::TextRenderingHintAntiAlias); 199 200 PreDrawLyric(pGraphics); 201 bool bDrawTranslate = m_bShowTranslate && !m_strTranslate.IsEmpty(); 202 if (m_bDoubleLine && !m_strNextLyric.IsEmpty() && !bDrawTranslate) 203 DrawLyricsDoubleLine(pGraphics); 204 else 205 DrawLyrics(pGraphics); 206 AfterDrawLyric(pGraphics); 207 208 delete pGraphics; 209 //---------------------------------- 210 //设置透明窗口 211 CPoint DestPt(0,0); 212 CSize psize(m_nWidth,m_nHeight); 213 BLENDFUNCTION blendFunc32bpp; 214 blendFunc32bpp.AlphaFormat = AC_SRC_ALPHA; 215 blendFunc32bpp.BlendFlags = 0; 216 blendFunc32bpp.BlendOp = AC_SRC_OVER; 217 blendFunc32bpp.SourceConstantAlpha = m_alpha; 218 HDC hDC=::GetDC(m_hWnd); 219 ::UpdateLayeredWindow(m_hWnd,hDC,NULL,&psize,m_hCacheDC,&DestPt,0,&blendFunc32bpp,ULW_ALPHA); 220 //---------------------------------- 221 //释放资源 222 ::SelectObject (m_hCacheDC,hOldBitmap); 223 ::DeleteObject(hBitmap); 224 ::ReleaseDC(m_hWnd,hDC); 225 } 226 227 void CLyricsWindow::DrawLyricText(Gdiplus::Graphics* pGraphics, LPCTSTR strText, Gdiplus::RectF rect, bool bDrawHighlight, bool bDrawTranslate) 228 { 229 Gdiplus::REAL fontSize = bDrawTranslate ? m_FontSize * TRANSLATE_FONT_SIZE_FACTOR : m_FontSize; 230 if (fontSize < 1) 231 fontSize = m_FontSize; 232 233 Gdiplus::REAL textWidth = rect.Width; 234 Gdiplus::REAL highlighWidth = rect.Width * m_nHighlight / 1000; 235 236 if (!bDrawHighlight && !bDrawTranslate) 237 { 238 if (rect.X < 0) 239 rect.X = 0; 240 } 241 else 242 { 243 //如果文本宽度大于控件宽度,就要根据分割的位置滚动文本 244 if (textWidth > m_nWidth) 245 { 246 //如果分割的位置(歌词进度)剩下的宽度已经小于控件宽度的一半,此时使文本右侧和控件右侧对齐 247 if (textWidth - highlighWidth < m_nWidth / 2) 248 { 249 rect.X = m_nWidth - textWidth; 250 } 251 //分割位置剩下的宽度还没有到小于控件宽度的一半,但是分割位置的宽度已经大于控件宽度的一半时,需要移动文本使分割位置正好在控件的中间 252 else if (highlighWidth > m_nWidth / 2) 253 { 254 rect.X = m_nWidth / 2 - highlighWidth; 255 } 256 //分割位置还不到控件宽度的一半时,使文本左侧和控件左侧对齐 257 else 258 { 259 rect.X = 0; 260 } 261 } 262 } 263 264 //----------------------------------------------------------- 265 //画出阴影 266 if (m_pShadowBrush) { 267 Gdiplus::RectF layoutRect(0, 0, 0, 0); 268 layoutRect = rect; 269 layoutRect.X = layoutRect.X + m_nShadowOffset; 270 layoutRect.Y = layoutRect.Y + m_nShadowOffset; 271 Gdiplus::GraphicsPath* pShadowPath = new Gdiplus::GraphicsPath(Gdiplus::FillModeAlternate);//创建路径 272 pShadowPath->AddString(strText, -1, m_pFontFamily, m_FontStyle, fontSize, layoutRect, m_pTextFormat); //把文字加入路径 273 pGraphics->FillPath(m_pShadowBrush, pShadowPath);//填充路径 274 delete pShadowPath; //销毁路径 275 } 276 277 //----------------------------------------------------------- 278 //画出歌词 279 Gdiplus::GraphicsPath* pStringPath = new Gdiplus::GraphicsPath(Gdiplus::FillModeAlternate);//创建路径 280 pStringPath->AddString(strText, -1, m_pFontFamily, m_FontStyle, fontSize, rect, m_pTextFormat); //把文字加入路径 281 if (m_pTextPen) { 282 pGraphics->DrawPath(m_pTextPen, pStringPath);//画路径,文字边框 283 } 284 Gdiplus::Brush* pBrush = CreateGradientBrush(m_TextGradientMode, m_TextColor1, m_TextColor2, rect); 285 pGraphics->FillPath(pBrush, pStringPath);//填充路径 286 delete pBrush;//销毁画刷 287 if(bDrawHighlight) 288 DrawHighlightLyrics(pGraphics, pStringPath, rect); 289 delete pStringPath; //销毁路径 290 } 291 292 //绘制歌词 293 void CLyricsWindow::DrawLyrics(Gdiplus::Graphics* pGraphics) 294 { 295 int lyricHeight = m_nHeight - m_toobar_height; 296 //先取出文字宽度和高度 297 Gdiplus::RectF layoutRect(0,0,0,0); 298 Gdiplus::RectF boundingBox; 299 pGraphics->MeasureString (m_lpszLyrics, -1, m_pFont,layoutRect, m_pTextFormat,&boundingBox, 0, 0); 300 //计算歌词画出的位置 301 Gdiplus::RectF dstRect; //文字的矩形 302 Gdiplus::RectF transRect; //翻译文本的矩形 303 bool bDrawTranslate = m_bShowTranslate && !m_strTranslate.IsEmpty(); 304 if(!bDrawTranslate) 305 { 306 dstRect = Gdiplus::RectF((m_nWidth - boundingBox.Width) / 2, m_toobar_height + (lyricHeight - boundingBox.Height) / 2, boundingBox.Width, boundingBox.Height); 307 } 308 else 309 { 310 Gdiplus::RectF transBoundingBox; 311 pGraphics->MeasureString(m_strTranslate, -1, m_pFont, layoutRect, m_pTextFormat, &transBoundingBox, 0, 0); 312 Gdiplus::REAL translateHeight = transBoundingBox.Height * TRANSLATE_FONT_SIZE_FACTOR; 313 Gdiplus::REAL translateWidth = transBoundingBox.Width * TRANSLATE_FONT_SIZE_FACTOR; 314 Gdiplus::REAL gapHeight = boundingBox.Height * 0.2f; //歌词和翻译之间的间隙 315 Gdiplus::REAL height = boundingBox.Height + gapHeight + translateHeight; 316 dstRect = Gdiplus::RectF((m_nWidth - boundingBox.Width) / 2, m_toobar_height + (lyricHeight - height) / 2, boundingBox.Width, boundingBox.Height); 317 transRect = Gdiplus::RectF((m_nWidth - translateWidth) / 2, dstRect.GetBottom() + gapHeight, translateWidth, translateHeight); 318 } 319 320 DrawLyricText(pGraphics, m_lpszLyrics, dstRect, true); 321 if (bDrawTranslate) 322 DrawLyricText(pGraphics, m_strTranslate, transRect, false, true); 323 } 324 325 void CLyricsWindow::DrawLyricsDoubleLine(Gdiplus::Graphics* pGraphics) 326 { 327 int lyricHeight = m_nHeight - m_toobar_height; 328 static bool bSwap = false; 329 if (m_lyricChangeFlag) //如果歌词发生了改变,则交换当前歌词和下一句歌词的位置 330 bSwap = !bSwap; 331 //先取出文字宽度和高度 332 Gdiplus::RectF layoutRect(0, 0, 0, 0); 333 Gdiplus::RectF boundingBox; 334 pGraphics->MeasureString(m_lpszLyrics, -1, m_pFont, layoutRect, m_pTextFormat, &boundingBox, 0, 0); 335 Gdiplus::RectF nextBoundingBox; 336 pGraphics->MeasureString(m_strNextLyric, -1, m_pFont, layoutRect, m_pTextFormat, &nextBoundingBox, 0, 0); 337 //计算歌词画出的位置 338 Gdiplus::RectF dstRect; //文字的矩形 339 Gdiplus::RectF nextRect; //下一句文本的矩形 340 341 dstRect = Gdiplus::RectF(0, m_toobar_height + (lyricHeight / 2 - boundingBox.Height) / 2, boundingBox.Width, boundingBox.Height); 342 nextRect = Gdiplus::RectF(m_nWidth - nextBoundingBox.Width, dstRect.Y + lyricHeight / 2, nextBoundingBox.Width, nextBoundingBox.Height); 343 344 if (bSwap) 345 { 346 std::swap(dstRect.Y, nextRect.Y); 347 nextRect.X = 0; 348 dstRect.X = m_nWidth - dstRect.Width; 349 } 350 351 DrawLyricText(pGraphics, m_lpszLyrics, dstRect, true); 352 DrawLyricText(pGraphics, m_strNextLyric, nextRect, false); 353 } 354 355 //绘制高亮歌词 356 void CLyricsWindow::DrawHighlightLyrics(Gdiplus::Graphics* pGraphics,Gdiplus::GraphicsPath* pPath, Gdiplus::RectF& dstRect) 357 { 358 if(m_nHighlight<=0)return; 359 Gdiplus::Region* pRegion=NULL; 360 if(m_nHighlight<1000){ 361 Gdiplus::RectF CliptRect(dstRect); 362 CliptRect.Width=CliptRect.Width * m_nHighlight / 1000; 363 pRegion=new Gdiplus::Region(CliptRect); 364 pGraphics->SetClip(pRegion, Gdiplus::CombineModeReplace); 365 } 366 //-------------------------------------------- 367 if(m_pHighlightPen){ 368 pGraphics->DrawPath (m_pHighlightPen,pPath);//画路径,文字边框 369 } 370 Gdiplus::Brush* pBrush = CreateGradientBrush(m_HighlightGradientMode, m_HighlightColor1,m_HighlightColor2,dstRect); 371 pGraphics->FillPath (pBrush,pPath);//填充路径 372 delete pBrush;//销毁画刷 373 //-------------------------------------------- 374 if(pRegion){ 375 pGraphics->ResetClip(); 376 delete pRegion; 377 } 378 } 379 380 //创建渐变画刷 381 Gdiplus::Brush* CLyricsWindow::CreateGradientBrush(LyricsGradientMode TextGradientMode,Gdiplus::Color& Color1,Gdiplus::Color& Color2, Gdiplus::RectF& dstRect) 382 { 383 Gdiplus::PointF pt1; 384 Gdiplus::PointF pt2; 385 Gdiplus::Brush* pBrush=NULL; 386 switch (TextGradientMode) 387 { 388 case LyricsGradientMode_Two://两色渐变 389 { 390 Gdiplus::PointF point1(dstRect.X,dstRect.Y); 391 Gdiplus::PointF point2(dstRect.X,dstRect.Y+dstRect.Height); 392 pBrush=new Gdiplus::LinearGradientBrush(point1,point2,Color1,Color2); 393 ((Gdiplus::LinearGradientBrush*)pBrush)->SetWrapMode(Gdiplus::WrapModeTileFlipXY); 394 break; 395 } 396 397 case LyricsGradientMode_Three://三色渐变 398 { 399 Gdiplus::PointF point1(dstRect.X,dstRect.Y); 400 Gdiplus::PointF point2(dstRect.X,dstRect.Y+dstRect.Height/2); 401 pBrush=new Gdiplus::LinearGradientBrush(point1,point2,Color1,Color2); 402 ((Gdiplus::LinearGradientBrush*)pBrush)->SetWrapMode(Gdiplus::WrapModeTileFlipXY); 403 break; 404 } 405 406 default://无渐变 407 { 408 pBrush=new Gdiplus::SolidBrush(Color1); 409 break; 410 } 411 } 412 return pBrush; 413 } 414 415 //设置歌词颜色 416 void CLyricsWindow::SetLyricsColor(Gdiplus::Color TextColor1) 417 { 418 CLyricsWindow::SetLyricsColor(TextColor1,Gdiplus::Color::Black,LyricsGradientMode_None); 419 } 420 void CLyricsWindow::SetLyricsColor(Gdiplus::Color TextColor1,Gdiplus::Color TextColor2,LyricsGradientMode TextGradientMode) 421 { 422 m_TextColor1=TextColor1; 423 m_TextColor2=TextColor2; 424 m_TextGradientMode=TextGradientMode; 425 426 } 427 //设置歌词边框 428 void CLyricsWindow::SetLyricsBorder(Gdiplus::Color BorderColor, Gdiplus::REAL BorderWidth) 429 { 430 if(m_pTextPen){ 431 delete m_pTextPen; 432 m_pTextPen=NULL; 433 } 434 if(BorderColor.GetA()>0 && BorderWidth>0) 435 m_pTextPen=new Gdiplus::Pen(BorderColor,BorderWidth); 436 } 437 //设置高亮歌词颜色 438 void CLyricsWindow::SetHighlightColor(Gdiplus::Color TextColor1) 439 { 440 CLyricsWindow::SetHighlightColor(TextColor1,Gdiplus::Color::Black,LyricsGradientMode_None); 441 } 442 void CLyricsWindow::SetHighlightColor(Gdiplus::Color TextColor1,Gdiplus::Color TextColor2,LyricsGradientMode TextGradientMode) 443 { 444 m_HighlightColor1=TextColor1; 445 m_HighlightColor2=TextColor2; 446 m_HighlightGradientMode=TextGradientMode; 447 448 } 449 //设置高亮歌词边框 450 void CLyricsWindow::SetHighlightBorder(Gdiplus::Color BorderColor, Gdiplus::REAL BorderWidth) 451 { 452 if(m_pHighlightPen){ 453 delete m_pHighlightPen; 454 m_pHighlightPen=NULL; 455 } 456 if(BorderColor.GetA()>0 && BorderWidth>0) 457 m_pHighlightPen=new Gdiplus::Pen(BorderColor,BorderWidth); 458 } 459 //设置歌词阴影 460 void CLyricsWindow::SetLyricsShadow(Gdiplus::Color ShadowColor,int nShadowOffset) 461 { 462 if(m_pShadowBrush){ 463 delete m_pShadowBrush; 464 m_pShadowBrush=NULL; 465 } 466 if(ShadowColor.GetA()>0 && nShadowOffset>0){ 467 m_nShadowOffset=nShadowOffset; 468 m_pShadowBrush=new Gdiplus::SolidBrush(ShadowColor); 469 }else{ 470 m_nShadowOffset=0; 471 } 472 } 473 //设置歌词字体 474 void CLyricsWindow::SetLyricsFont(const WCHAR * familyName, Gdiplus::REAL emSize,INT style, Gdiplus::Unit unit) 475 { 476 if(m_pFont){ 477 delete m_pFont; 478 m_pFont=NULL; 479 } 480 Gdiplus::FontFamily family(familyName,NULL); 481 Gdiplus::Status lastResult = family.GetLastStatus(); 482 if (lastResult != Gdiplus::Ok) 483 { 484 HFONT hFont=(HFONT)GetStockObject(DEFAULT_GUI_FONT); 485 LOGFONTW lf; 486 ZeroMemory(&lf,sizeof(LOGFONTW)); 487 GetObjectW(hFont,sizeof(LOGFONTW),&lf); 488 Gdiplus::FontFamily family2(lf.lfFaceName,NULL); 489 m_pFont=new Gdiplus::Font(&family2,emSize,style,unit); 490 }else{ 491 m_pFont=new Gdiplus::Font(&family,emSize,style,unit); 492 } 493 //---------------- 494 //保存一些字体属性,加入路径时要用到 495 m_pFont->GetFamily (m_pFontFamily); 496 m_FontSize=m_pFont->GetSize (); 497 m_FontStyle=m_pFont->GetStyle (); 498 499 500 501 } 502 503 void CLyricsWindow::SetLyricDoubleLine(bool doubleLine) 504 { 505 m_bDoubleLine = doubleLine; 506 } 507 508 void CLyricsWindow::SetNextLyric(LPCTSTR lpszNextLyric) 509 { 510 m_strNextLyric = lpszNextLyric; 511 } 512 513 void CLyricsWindow::SetShowTranslate(bool showTranslate) 514 { 515 m_bShowTranslate = showTranslate; 516 } 517 518 void CLyricsWindow::SetAlpha(int alpha) 519 { 520 m_alpha = alpha; 521 } 522 523 const CString& CLyricsWindow::GetLyricStr() const 524 { 525 return m_lpszLyrics; 526 } 527 528 void CLyricsWindow::SetLyricChangeFlag(bool bFlag) 529 { 530 m_lyricChangeFlag = bFlag; 531 } 532 533 void CLyricsWindow::OnLButtonDown(UINT nFlags, CPoint point) 534 { 535 536 CWnd::OnLButtonDown(nFlags, point); 537 //ReleaseCapture(); 538 //SendMessage(WM_NCLBUTTONDOWN,HTCAPTION,NULL); 539 } 540 541