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 if (m_bDoubleLine && !m_strNextLyric.IsEmpty()) 202 DrawLyricsDoubleLine(pGraphics); 203 else 204 DrawLyrics(pGraphics); 205 AfterDrawLyric(pGraphics); 206 207 delete pGraphics; 208 //---------------------------------- 209 //���������� 210 CPoint DestPt(0,0); 211 CSize psize(m_nWidth,m_nHeight); 212 BLENDFUNCTION blendFunc32bpp; 213 blendFunc32bpp.AlphaFormat = AC_SRC_ALPHA; 214 blendFunc32bpp.BlendFlags = 0; 215 blendFunc32bpp.BlendOp = AC_SRC_OVER; 216 blendFunc32bpp.SourceConstantAlpha = m_alpha; 217 HDC hDC=::GetDC(m_hWnd); 218 ::UpdateLayeredWindow(m_hWnd,hDC,NULL,&psize,m_hCacheDC,&DestPt,0,&blendFunc32bpp,ULW_ALPHA); 219 //---------------------------------- 220 //�ͷ���Դ 221 ::SelectObject (m_hCacheDC,hOldBitmap); 222 ::DeleteObject(hBitmap); 223 ::ReleaseDC(m_hWnd,hDC); 224 } 225 226 void CLyricsWindow::DrawLyricText(Gdiplus::Graphics* pGraphics, LPCTSTR strText, Gdiplus::RectF rect, bool bDrawHighlight, bool bDrawTranslate) 227 { 228 Gdiplus::REAL fontSize = bDrawTranslate ? m_FontSize * TRANSLATE_FONT_SIZE_FACTOR : m_FontSize; 229 if (fontSize < 1) 230 fontSize = m_FontSize; 231 232 Gdiplus::REAL textWidth = rect.Width; 233 Gdiplus::REAL highlighWidth = rect.Width * m_nHighlight / 1000; 234 235 if (!bDrawHighlight && !bDrawTranslate) 236 { 237 if (rect.X < 0) 238 rect.X = 0; 239 } 240 else 241 { 242 //����ı���ȴ��ڿؼ���ȣ���Ҫ���ݷָ��λ�ù����ı� 243 if (textWidth > m_nWidth) 244 { 245 //����ָ��λ�ã���ʽ��ȣ�ʣ�µĿ���Ѿ�С�ڿؼ���ȵ�һ�룬��ʱʹ�ı��Ҳ�Ϳؼ��Ҳ���� 246 if (textWidth - highlighWidth < m_nWidth / 2) 247 { 248 rect.X = m_nWidth - textWidth; 249 } 250 //�ָ�λ��ʣ�µĿ�Ȼ�û�е�С�ڿؼ���ȵ�һ�룬���Ƿָ�λ�õĿ���Ѿ����ڿؼ���ȵ�һ��ʱ����Ҫ�ƶ��ı�ʹ�ָ�λ�������ڿؼ����м� 251 else if (highlighWidth > m_nWidth / 2) 252 { 253 rect.X = m_nWidth / 2 - highlighWidth; 254 } 255 //�ָ�λ�û������ؼ���ȵ�һ��ʱ��ʹ�ı����Ϳؼ������� 256 else 257 { 258 rect.X = 0; 259 } 260 } 261 } 262 263 //----------------------------------------------------------- 264 //������Ӱ 265 if (m_pShadowBrush) { 266 Gdiplus::RectF layoutRect(0, 0, 0, 0); 267 layoutRect = rect; 268 layoutRect.X = layoutRect.X + m_nShadowOffset; 269 layoutRect.Y = layoutRect.Y + m_nShadowOffset; 270 Gdiplus::GraphicsPath* pShadowPath = new Gdiplus::GraphicsPath(Gdiplus::FillModeAlternate);//����·�� 271 pShadowPath->AddString(strText, -1, m_pFontFamily, m_FontStyle, fontSize, layoutRect, m_pTextFormat); //�����ּ���·�� 272 pGraphics->FillPath(m_pShadowBrush, pShadowPath);//���·�� 273 delete pShadowPath; //����·�� 274 } 275 276 //----------------------------------------------------------- 277 //������� 278 Gdiplus::GraphicsPath* pStringPath = new Gdiplus::GraphicsPath(Gdiplus::FillModeAlternate);//����·�� 279 pStringPath->AddString(strText, -1, m_pFontFamily, m_FontStyle, fontSize, rect, m_pTextFormat); //�����ּ���·�� 280 if (m_pTextPen) { 281 pGraphics->DrawPath(m_pTextPen, pStringPath);//��·��,���ֱ߿� 282 } 283 Gdiplus::Brush* pBrush = CreateGradientBrush(m_TextGradientMode, m_TextColor1, m_TextColor2, rect); 284 pGraphics->FillPath(pBrush, pStringPath);//���·�� 285 delete pBrush;//���ٻ�ˢ 286 if(bDrawHighlight) 287 DrawHighlightLyrics(pGraphics, pStringPath, rect); 288 delete pStringPath; //����·�� 289 } 290 291 //���Ƹ�� 292 void CLyricsWindow::DrawLyrics(Gdiplus::Graphics* pGraphics) 293 { 294 int lyricHeight = m_nHeight - m_toobar_height; 295 //��ȡ�����ֿ�Ⱥ߶� 296 Gdiplus::RectF layoutRect(0,0,0,0); 297 Gdiplus::RectF boundingBox; 298 pGraphics->MeasureString (m_lpszLyrics, -1, m_pFont,layoutRect, m_pTextFormat,&boundingBox, 0, 0); 299 //�����ʻ�����λ�� 300 Gdiplus::RectF dstRect; //���ֵľ��� 301 Gdiplus::RectF transRect; //�����ı��ľ��� 302 bool bDrawTranslate = m_bShowTranslate && !m_strTranslate.IsEmpty(); 303 if(!bDrawTranslate) 304 { 305 dstRect = Gdiplus::RectF((m_nWidth - boundingBox.Width) / 2, m_toobar_height + (lyricHeight - boundingBox.Height) / 2, boundingBox.Width, boundingBox.Height); 306 } 307 else 308 { 309 Gdiplus::RectF transBoundingBox; 310 pGraphics->MeasureString(m_strTranslate, -1, m_pFont, layoutRect, m_pTextFormat, &transBoundingBox, 0, 0); 311 Gdiplus::REAL translateHeight = transBoundingBox.Height * TRANSLATE_FONT_SIZE_FACTOR; 312 Gdiplus::REAL translateWidth = transBoundingBox.Width * TRANSLATE_FONT_SIZE_FACTOR; 313 Gdiplus::REAL gapHeight = boundingBox.Height * 0.2f; //��ʺͷ���֮��ļ�϶ 314 Gdiplus::REAL height = boundingBox.Height + gapHeight + translateHeight; 315 dstRect = Gdiplus::RectF((m_nWidth - boundingBox.Width) / 2, m_toobar_height + (lyricHeight - height) / 2, boundingBox.Width, boundingBox.Height); 316 transRect = Gdiplus::RectF((m_nWidth - translateWidth) / 2, dstRect.GetBottom() + gapHeight, translateWidth, translateHeight); 317 } 318 319 DrawLyricText(pGraphics, m_lpszLyrics, dstRect, true); 320 if (bDrawTranslate) 321 DrawLyricText(pGraphics, m_strTranslate, transRect, false, true); 322 } 323 324 void CLyricsWindow::DrawLyricsDoubleLine(Gdiplus::Graphics* pGraphics) 325 { 326 int lyricHeight = m_nHeight - m_toobar_height; 327 static bool bSwap = false; 328 if (m_lyricChangeFlag) //�����ʷ����˸ı䣬����ǰ��ʺ���һ���ʵ�λ�� 329 bSwap = !bSwap; 330 //��ȡ�����ֿ�Ⱥ߶� 331 Gdiplus::RectF layoutRect(0, 0, 0, 0); 332 Gdiplus::RectF boundingBox; 333 pGraphics->MeasureString(m_lpszLyrics, -1, m_pFont, layoutRect, m_pTextFormat, &boundingBox, 0, 0); 334 Gdiplus::RectF nextBoundingBox; 335 pGraphics->MeasureString(m_strNextLyric, -1, m_pFont, layoutRect, m_pTextFormat, &nextBoundingBox, 0, 0); 336 //�����ʻ�����λ�� 337 Gdiplus::RectF dstRect; //���ֵľ��� 338 Gdiplus::RectF nextRect; //��һ���ı��ľ��� 339 340 dstRect = Gdiplus::RectF(0, m_toobar_height + (lyricHeight / 2 - boundingBox.Height) / 2, boundingBox.Width, boundingBox.Height); 341 nextRect = Gdiplus::RectF(m_nWidth - nextBoundingBox.Width, dstRect.Y + lyricHeight / 2, nextBoundingBox.Width, nextBoundingBox.Height); 342 343 if (bSwap) 344 { 345 std::swap(dstRect.Y, nextRect.Y); 346 nextRect.X = 0; 347 dstRect.X = m_nWidth - dstRect.Width; 348 } 349 350 DrawLyricText(pGraphics, m_lpszLyrics, dstRect, true); 351 DrawLyricText(pGraphics, m_strNextLyric, nextRect, false); 352 } 353 354 //���Ƹ������ 355 void CLyricsWindow::DrawHighlightLyrics(Gdiplus::Graphics* pGraphics,Gdiplus::GraphicsPath* pPath, Gdiplus::RectF& dstRect) 356 { 357 if(m_nHighlight<=0)return; 358 Gdiplus::Region* pRegion=NULL; 359 if(m_nHighlight<1000){ 360 Gdiplus::RectF CliptRect(dstRect); 361 CliptRect.Width=CliptRect.Width * m_nHighlight / 1000; 362 pRegion=new Gdiplus::Region(CliptRect); 363 pGraphics->SetClip(pRegion, Gdiplus::CombineModeReplace); 364 } 365 //-------------------------------------------- 366 if(m_pHighlightPen){ 367 pGraphics->DrawPath (m_pHighlightPen,pPath);//��·��,���ֱ߿� 368 } 369 Gdiplus::Brush* pBrush = CreateGradientBrush(m_HighlightGradientMode, m_HighlightColor1,m_HighlightColor2,dstRect); 370 pGraphics->FillPath (pBrush,pPath);//���·�� 371 delete pBrush;//���ٻ�ˢ 372 //-------------------------------------------- 373 if(pRegion){ 374 pGraphics->ResetClip(); 375 delete pRegion; 376 } 377 } 378 379 //�������仭ˢ 380 Gdiplus::Brush* CLyricsWindow::CreateGradientBrush(LyricsGradientMode TextGradientMode,Gdiplus::Color& Color1,Gdiplus::Color& Color2, Gdiplus::RectF& dstRect) 381 { 382 Gdiplus::PointF pt1; 383 Gdiplus::PointF pt2; 384 Gdiplus::Brush* pBrush=NULL; 385 switch (TextGradientMode) 386 { 387 case LyricsGradientMode_Two://��ɫ���� 388 { 389 Gdiplus::PointF point1(dstRect.X,dstRect.Y); 390 Gdiplus::PointF point2(dstRect.X,dstRect.Y+dstRect.Height); 391 pBrush=new Gdiplus::LinearGradientBrush(point1,point2,Color1,Color2); 392 ((Gdiplus::LinearGradientBrush*)pBrush)->SetWrapMode(Gdiplus::WrapModeTileFlipXY); 393 break; 394 } 395 396 case LyricsGradientMode_Three://��ɫ���� 397 { 398 Gdiplus::PointF point1(dstRect.X,dstRect.Y); 399 Gdiplus::PointF point2(dstRect.X,dstRect.Y+dstRect.Height/2); 400 pBrush=new Gdiplus::LinearGradientBrush(point1,point2,Color1,Color2); 401 ((Gdiplus::LinearGradientBrush*)pBrush)->SetWrapMode(Gdiplus::WrapModeTileFlipXY); 402 break; 403 } 404 405 default://���� 406 { 407 pBrush=new Gdiplus::SolidBrush(Color1); 408 break; 409 } 410 } 411 return pBrush; 412 } 413 414 //���ø����ɫ 415 void CLyricsWindow::SetLyricsColor(Gdiplus::Color TextColor1) 416 { 417 CLyricsWindow::SetLyricsColor(TextColor1,Gdiplus::Color::Black,LyricsGradientMode_None); 418 } 419 void CLyricsWindow::SetLyricsColor(Gdiplus::Color TextColor1,Gdiplus::Color TextColor2,LyricsGradientMode TextGradientMode) 420 { 421 m_TextColor1=TextColor1; 422 m_TextColor2=TextColor2; 423 m_TextGradientMode=TextGradientMode; 424 425 } 426 //���ø�ʱ߿� 427 void CLyricsWindow::SetLyricsBorder(Gdiplus::Color BorderColor, Gdiplus::REAL BorderWidth) 428 { 429 if(m_pTextPen){ 430 delete m_pTextPen; 431 m_pTextPen=NULL; 432 } 433 if(BorderColor.GetA()>0 && BorderWidth>0) 434 m_pTextPen=new Gdiplus::Pen(BorderColor,BorderWidth); 435 } 436 //���ø��������ɫ 437 void CLyricsWindow::SetHighlightColor(Gdiplus::Color TextColor1) 438 { 439 CLyricsWindow::SetHighlightColor(TextColor1,Gdiplus::Color::Black,LyricsGradientMode_None); 440 } 441 void CLyricsWindow::SetHighlightColor(Gdiplus::Color TextColor1,Gdiplus::Color TextColor2,LyricsGradientMode TextGradientMode) 442 { 443 m_HighlightColor1=TextColor1; 444 m_HighlightColor2=TextColor2; 445 m_HighlightGradientMode=TextGradientMode; 446 447 } 448 //���ø�����ʱ߿� 449 void CLyricsWindow::SetHighlightBorder(Gdiplus::Color BorderColor, Gdiplus::REAL BorderWidth) 450 { 451 if(m_pHighlightPen){ 452 delete m_pHighlightPen; 453 m_pHighlightPen=NULL; 454 } 455 if(BorderColor.GetA()>0 && BorderWidth>0) 456 m_pHighlightPen=new Gdiplus::Pen(BorderColor,BorderWidth); 457 } 458 //���ø����Ӱ 459 void CLyricsWindow::SetLyricsShadow(Gdiplus::Color ShadowColor,int nShadowOffset) 460 { 461 if(m_pShadowBrush){ 462 delete m_pShadowBrush; 463 m_pShadowBrush=NULL; 464 } 465 if(ShadowColor.GetA()>0 && nShadowOffset>0){ 466 m_nShadowOffset=nShadowOffset; 467 m_pShadowBrush=new Gdiplus::SolidBrush(ShadowColor); 468 }else{ 469 m_nShadowOffset=0; 470 } 471 } 472 //���ø������ 473 void CLyricsWindow::SetLyricsFont(const WCHAR * familyName, Gdiplus::REAL emSize,INT style, Gdiplus::Unit unit) 474 { 475 if(m_pFont){ 476 delete m_pFont; 477 m_pFont=NULL; 478 } 479 Gdiplus::FontFamily family(familyName,NULL); 480 Gdiplus::Status lastResult = family.GetLastStatus(); 481 if (lastResult != Gdiplus::Ok) 482 { 483 HFONT hFont=(HFONT)GetStockObject(DEFAULT_GUI_FONT); 484 LOGFONTW lf; 485 ZeroMemory(&lf,sizeof(LOGFONTW)); 486 GetObjectW(hFont,sizeof(LOGFONTW),&lf); 487 Gdiplus::FontFamily family2(lf.lfFaceName,NULL); 488 m_pFont=new Gdiplus::Font(&family2,emSize,style,unit); 489 }else{ 490 m_pFont=new Gdiplus::Font(&family,emSize,style,unit); 491 } 492 //---------------- 493 //����һЩ��������,����·��ʱҪ�õ� 494 m_pFont->GetFamily (m_pFontFamily); 495 m_FontSize=m_pFont->GetSize (); 496 m_FontStyle=m_pFont->GetStyle (); 497 498 499 500 } 501 502 void CLyricsWindow::SetLyricDoubleLine(bool doubleLine) 503 { 504 m_bDoubleLine = doubleLine; 505 } 506 507 void CLyricsWindow::SetNextLyric(LPCTSTR lpszNextLyric) 508 { 509 m_strNextLyric = lpszNextLyric; 510 } 511 512 void CLyricsWindow::SetShowTranslate(bool showTranslate) 513 { 514 m_bShowTranslate = showTranslate; 515 } 516 517 void CLyricsWindow::SetAlpha(int alpha) 518 { 519 m_alpha = alpha; 520 } 521 522 const CString& CLyricsWindow::GetLyricStr() const 523 { 524 return m_lpszLyrics; 525 } 526 527 void CLyricsWindow::SetLyricChangeFlag(bool bFlag) 528 { 529 m_lyricChangeFlag = bFlag; 530 } 531 532 void CLyricsWindow::OnLButtonDown(UINT nFlags, CPoint point) 533 { 534 535 CWnd::OnLButtonDown(nFlags, point); 536 //ReleaseCapture(); 537 //SendMessage(WM_NCLBUTTONDOWN,HTCAPTION,NULL); 538 } 539 540