Support unrar64.dll
[xy_vsfilter.git] / src / thirdparty / mfc / afxglobals.cpp
blob8dda67bfcea4bf20af5438a629a25d288119c021
1 // This is a part of the Microsoft Foundation Classes C++ library.
2 // Copyright (C) Microsoft Corporation
3 // All rights reserved.
4 //
5 // This source code is only intended as a supplement to the
6 // Microsoft Foundation Classes Reference and related
7 // electronic documentation provided with the library.
8 // See these sources for detailed information regarding the
9 // Microsoft Foundation Classes product.
11 #include "stdafx.h"
12 #include "comdef.h"
13 // #include "afxcontrolbarutil.h"
14 #include "afxglobals.h"
16 #pragma warning(disable:4995 4996)
18 #if defined(__INTEL_COMPILER)
19 #pragma warning(disable:810)
20 #endif
22 #if 0
23 #include "afxvisualmanager.h"
24 #include "afxkeyboardmanager.h"
25 #include "afxmenuhash.h"
26 #include "afxtoolbar.h"
27 #include "afxmenuimages.h"
28 #include "afxpaneframewnd.h"
29 #include "afxdockingmanager.h"
30 #include "afxvisualmanageroffice2007.h"
31 #include "afxribbonres.h"
33 #include "afxframewndex.h"
34 #include "afxmdiframewndex.h"
35 #include "afxoleipframewndex.h"
36 #include "afxoledocipframewndex.h"
37 #include "afxmdichildwndex.h"
38 #endif
40 extern CObList afxAllToolBars;
42 BOOL CMemDC::m_bUseMemoryDC = TRUE;
44 #if (_MSC_VER == 1700)
46 #define AFX_FONT_NAME_OFFICE _T("Tahoma")
47 #define AFX_FONT_NAME_OFFICE_2007 _T("Segoe UI")
48 #define AFX_FONT_NAME_DEFAULT _T("MS Sans Serif")
49 #define AFX_FONT_NAME_VERT _T("Arial")
50 #define AFX_FONT_NAME_MARLETT _T("Marlett")
52 CMemDC::CMemDC(CDC& dc, CWnd* pWnd) :
53 m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL)
55 ASSERT_VALID(pWnd);
57 pWnd->GetClientRect(m_rect);
59 m_rect.right += pWnd->GetScrollPos(SB_HORZ);
60 m_rect.bottom += pWnd->GetScrollPos(SB_VERT);
62 HDC hdcPaint = NULL;
64 if (!GetGlobalData()->m_bBufferedPaintInited)
66 BufferedPaintInit();
67 GetGlobalData()->m_bBufferedPaintInited = TRUE;
70 m_hBufferedPaint = BeginBufferedPaint(dc.GetSafeHdc(), m_rect, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
72 if (m_hBufferedPaint != NULL && hdcPaint != NULL)
74 m_bMemDC = TRUE;
75 m_dcMem.Attach(hdcPaint);
79 CMemDC::CMemDC(CDC& dc, const CRect& rect) :
80 m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL), m_rect(rect)
82 ASSERT(!m_rect.IsRectEmpty());
84 HDC hdcPaint = NULL;
86 if (!GetGlobalData()->m_bBufferedPaintInited)
88 BufferedPaintInit();
89 GetGlobalData()->m_bBufferedPaintInited = TRUE;
92 m_hBufferedPaint = BeginBufferedPaint(dc.GetSafeHdc(), m_rect, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
94 if (m_hBufferedPaint != NULL && hdcPaint != NULL)
96 m_bMemDC = TRUE;
97 m_dcMem.Attach(hdcPaint);
101 CMemDC::~CMemDC()
103 if (m_hBufferedPaint != NULL)
105 m_dcMem.Detach();
106 EndBufferedPaint(m_hBufferedPaint, TRUE);
110 static int CALLBACK FontFamilyProcFonts(const LOGFONT FAR* lplf, const TEXTMETRIC FAR* /*lptm*/, ULONG /*ulFontType*/, LPARAM lParam)
112 ENSURE(lplf != NULL);
113 ENSURE(lParam != NULL);
115 CString strFont = lplf->lfFaceName;
116 return strFont.CollateNoCase((LPCTSTR) lParam) == 0 ? 0 : 1;
119 /////////////////////////////////////////////////////////////////////////////
120 // Cached system metrics, etc
121 AFX_GLOBAL_DATA afxGlobalData;
123 #ifdef _AFXDLL
124 // Reference count on global data
125 DWORD g_dwAfxGlobalDataRef = 0;
126 #endif
128 AFX_GLOBAL_DATA::AFX_GLOBAL_DATA()
130 m_bInitialized = FALSE;
131 m_bIsRibbonImageScale = TRUE;
133 // Cached system values(updated in CWnd::OnSysColorChange)
134 hbrBtnShadow = NULL;
135 hbrBtnHilite = NULL;
136 hbrWindow = NULL;
138 m_hcurStretch = NULL;
139 m_hcurStretchVert = NULL;
140 m_hcurHand = NULL;
141 m_hcurSizeAll = NULL;
142 m_hiconTool = NULL;
143 m_hiconLink = NULL;
144 m_hiconColors = NULL;
145 m_hcurMoveTab = NULL;
146 m_hcurNoMoveTab = NULL;
148 m_bUseSystemFont = FALSE;
149 m_bDontReduceFontHeight = FALSE;
150 m_bInSettingChange = FALSE;
152 m_bIsRTL = FALSE;
153 m_bBufferedPaintInited = FALSE;
155 m_nDragFrameThicknessFloat = 4; // pixels
156 m_nDragFrameThicknessDock = 3; // pixels
158 m_nAutoHideToolBarSpacing = 14; // pixels
159 m_nAutoHideToolBarMargin = 4; // pixels
161 m_nCoveredMainWndClientAreaPercent = 50; // percents
163 m_nMaxToolTipWidth = -1;
164 m_bIsBlackHighContrast = FALSE;
165 m_bIsWhiteHighContrast = FALSE;
167 m_bUseBuiltIn32BitIcons = TRUE;
169 #ifndef _AFXDLL
170 Initialize();
171 #endif
174 // Initialization code
175 void AFX_GLOBAL_DATA::Initialize()
177 if (m_bInitialized)
179 return;
182 OSVERSIONINFOEX osvi = { sizeof(osvi), HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7) };
184 // The condition mask specifies to test for the OS major/minor versions using greater than or equal.
185 DWORDLONG const dwlConditionMask = VerSetConditionMask(VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_MINORVERSION, VER_GREATER_EQUAL);
187 bIsWindows7 = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
189 bIsRemoteSession = GetSystemMetrics(SM_REMOTESESSION);
191 UpdateSysColors();
192 UpdateFonts();
193 OnSettingChange();
194 EnableAccessibilitySupport();
197 AFX_GLOBAL_DATA::~AFX_GLOBAL_DATA()
199 CleanUp();
202 void AFX_GLOBAL_DATA::UpdateFonts()
204 CWindowDC dc(NULL);
205 m_dblRibbonImageScale = dc.GetDeviceCaps(LOGPIXELSX) / 96.0f;
207 if (m_dblRibbonImageScale > 1. && m_dblRibbonImageScale < 1.1)
209 m_dblRibbonImageScale = 1.;
212 if (fontRegular.GetSafeHandle() != NULL)
214 ::DeleteObject(fontRegular.Detach());
217 if (fontTooltip.GetSafeHandle() != NULL)
219 ::DeleteObject(fontTooltip.Detach());
222 if (fontBold.GetSafeHandle() != NULL)
224 ::DeleteObject(fontBold.Detach());
227 if (fontDefaultGUIBold.GetSafeHandle() != NULL)
229 ::DeleteObject(fontDefaultGUIBold.Detach());
232 if (fontUnderline.GetSafeHandle() != NULL)
234 ::DeleteObject(fontUnderline.Detach());
237 if (fontDefaultGUIUnderline.GetSafeHandle() != NULL)
239 ::DeleteObject(fontDefaultGUIUnderline.Detach());
242 if (fontVert.GetSafeHandle() != NULL)
244 ::DeleteObject(fontVert.Detach());
247 if (fontVertCaption.GetSafeHandle() != NULL)
249 ::DeleteObject(fontVertCaption.Detach());
252 if (fontMarlett.GetSafeHandle() != NULL)
254 ::DeleteObject(fontMarlett.Detach());
257 if (fontSmall.GetSafeHandle() != NULL)
259 ::DeleteObject(fontSmall.Detach());
262 // Initialize fonts:
264 NONCLIENTMETRICS info;
265 info.cbSize = sizeof(info);
266 GetNonClientMetrics (info);
268 LOGFONT lf;
269 memset(&lf, 0, sizeof(LOGFONT));
271 lf.lfCharSet = (BYTE) GetTextCharsetInfo(dc.GetSafeHdc(), NULL, 0);
273 lf.lfHeight = info.lfMenuFont.lfHeight;
274 lf.lfWeight = info.lfMenuFont.lfWeight;
275 lf.lfItalic = info.lfMenuFont.lfItalic;
277 //------------------
278 // Adjust font size:
279 //------------------
280 int nFontHeight = lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight;
281 if (nFontHeight <= 12)
283 nFontHeight = 11;
285 else if (!m_bDontReduceFontHeight)
287 nFontHeight--;
290 lf.lfHeight = (lf.lfHeight < 0) ? -nFontHeight : nFontHeight;
292 // Check if we should use system font
293 lstrcpy(lf.lfFaceName, info.lfMenuFont.lfFaceName);
295 BOOL fUseSystemFont = m_bUseSystemFont || (info.lfMenuFont.lfCharSet > SYMBOL_CHARSET);
296 if (!fUseSystemFont)
298 // Check for "Segoe UI" or "Tahoma" font existance:
299 if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamilyProcFonts, (LPARAM)(LPCTSTR) AFX_FONT_NAME_OFFICE_2007) == 0)
301 // Found! Use MS Office 2007 font!
302 lstrcpy(lf.lfFaceName, AFX_FONT_NAME_OFFICE_2007);
303 lf.lfQuality = 5 /*CLEARTYPE_QUALITY*/;
305 else if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamilyProcFonts, (LPARAM)(LPCTSTR) AFX_FONT_NAME_OFFICE) == 0)
307 // Found! Use MS Office font!
308 lstrcpy(lf.lfFaceName, AFX_FONT_NAME_OFFICE);
310 else
312 // Not found. Use default font:
313 lstrcpy(lf.lfFaceName, AFX_FONT_NAME_DEFAULT);
317 fontRegular.CreateFontIndirect(&lf);
319 // Create small font:
320 LONG lfHeightSaved = lf.lfHeight;
322 lf.lfHeight = (long)((1. + abs(lf.lfHeight)) * 2 / 3);
323 if (lfHeightSaved < 0)
325 lf.lfHeight = -lf.lfHeight;
328 fontSmall.CreateFontIndirect(&lf);
329 lf.lfHeight = lfHeightSaved;
331 // Create tooltip font:
332 NONCLIENTMETRICS ncm;
333 ncm.cbSize = sizeof(ncm);
334 GetNonClientMetrics (ncm);
336 lf.lfItalic = ncm.lfStatusFont.lfItalic;
337 lf.lfWeight = ncm.lfStatusFont.lfWeight;
338 fontTooltip.CreateFontIndirect(&lf);
340 lf.lfItalic = info.lfMenuFont.lfItalic;
341 lf.lfWeight = info.lfMenuFont.lfWeight;
343 // Create "underline" font:
344 lf.lfUnderline = TRUE;
345 fontUnderline.CreateFontIndirect(&lf);
346 lf.lfUnderline = FALSE;
348 // Create bold font:
349 lf.lfWeight = FW_BOLD;
350 fontBold.CreateFontIndirect(&lf);
352 // Create Marlett font:
353 BYTE bCharSet = lf.lfCharSet;
354 lf.lfWeight = info.lfMenuFont.lfWeight;
355 lf.lfCharSet = SYMBOL_CHARSET;
356 lf.lfWeight = 0;
357 lf.lfHeight = ::GetSystemMetrics(SM_CYMENUCHECK) - 1;
358 lstrcpy(lf.lfFaceName, AFX_FONT_NAME_MARLETT);
360 fontMarlett.CreateFontIndirect(&lf);
361 lf.lfCharSet = bCharSet; // Restore charset
363 // Create vertical font:
364 CFont font;
365 if (font.CreateStockObject(DEFAULT_GUI_FONT))
367 if (font.GetLogFont(&lf) != 0)
369 lf.lfOrientation = 900;
370 lf.lfEscapement = 2700;
372 lf.lfHeight = info.lfMenuFont.lfHeight;
373 lf.lfWeight = info.lfMenuFont.lfWeight;
374 lf.lfItalic = info.lfMenuFont.lfItalic;
377 lstrcpy(lf.lfFaceName, AFX_FONT_NAME_VERT);
380 fontVert.CreateFontIndirect(&lf);
382 lf.lfEscapement = 900;
383 fontVertCaption.CreateFontIndirect(&lf);
387 // Create dialog underline and bold fonts:
388 CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
389 ASSERT_VALID(pDefaultGUIFont);
390 pDefaultGUIFont->GetLogFont(&lf);
392 lf.lfUnderline = TRUE;
393 fontDefaultGUIUnderline.CreateFontIndirect(&lf);
394 lf.lfUnderline = FALSE;
396 lf.lfWeight = FW_BOLD;
397 fontDefaultGUIBold.CreateFontIndirect(&lf);
399 UpdateTextMetrics();
401 #if 0
402 // Notify toolbars about font changing:
403 for (POSITION posTlb = afxAllToolBars.GetHeadPosition(); posTlb != NULL;)
405 CMFCToolBar* pToolBar = (CMFCToolBar*) afxAllToolBars.GetNext(posTlb);
406 ENSURE(pToolBar != NULL);
408 if (CWnd::FromHandlePermanent(pToolBar->m_hWnd) != NULL)
410 ASSERT_VALID(pToolBar);
411 pToolBar->OnGlobalFontsChanged();
414 #endif
417 static BOOL CALLBACK InfoEnumProc( HMONITOR hMonitor, HDC /*hdcMonitor*/, LPRECT /*lprcMonitor*/, LPARAM dwData)
419 CRect* pRect = (CRect*) dwData;
421 MONITORINFO mi;
422 mi.cbSize = sizeof(MONITORINFO);
424 if (GetMonitorInfo(hMonitor, &mi))
426 CRect rectMon = mi.rcWork;
428 pRect->left = min(pRect->left, rectMon.left);
429 pRect->right = max(pRect->right, rectMon.right);
430 pRect->top = min(pRect->top, rectMon.top);
431 pRect->bottom = max(pRect->bottom, rectMon.bottom);
434 return TRUE;
437 void AFX_GLOBAL_DATA::OnSettingChange()
439 m_bInSettingChange = TRUE;
441 m_sizeSmallIcon.cx = ::GetSystemMetrics(SM_CXSMICON);
442 m_sizeSmallIcon.cy = ::GetSystemMetrics(SM_CYSMICON);
444 m_rectVirtual.SetRectEmpty();
446 if (!EnumDisplayMonitors(NULL, NULL, InfoEnumProc, (LPARAM) &m_rectVirtual))
448 ::SystemParametersInfo(SPI_GETWORKAREA, 0, &m_rectVirtual, 0);
451 // Get system menu animation type:
452 m_bMenuAnimation = FALSE;
453 m_bMenuFadeEffect = FALSE;
455 if (!bIsRemoteSession)
457 ::SystemParametersInfo(SPI_GETMENUANIMATION, 0, &m_bMenuAnimation, 0);
459 if (m_bMenuAnimation)
461 ::SystemParametersInfo(SPI_GETMENUFADE, 0, &m_bMenuFadeEffect, 0);
465 m_nShellAutohideBars = 0;
466 m_bRefreshAutohideBars = TRUE;
468 ::SystemParametersInfo(SPI_GETMENUUNDERLINES, 0, &m_bSysUnderlineKeyboardShortcuts, 0);
469 m_bUnderlineKeyboardShortcuts = m_bSysUnderlineKeyboardShortcuts;
471 m_bInSettingChange = FALSE;
474 void AFX_GLOBAL_DATA::UpdateSysColors()
476 m_bIsBlackHighContrast = ::GetSysColor(COLOR_3DLIGHT) == RGB(255, 255, 255) && ::GetSysColor(COLOR_3DFACE) == RGB(0, 0, 0);
477 m_bIsWhiteHighContrast = ::GetSysColor(COLOR_3DDKSHADOW) == RGB(0, 0, 0) && ::GetSysColor(COLOR_3DFACE) == RGB(255, 255, 255);
479 CWindowDC dc(NULL);
480 m_nBitsPerPixel = dc.GetDeviceCaps(BITSPIXEL);
482 clrBarFace = clrBtnFace = ::GetSysColor(COLOR_BTNFACE);
483 clrBarShadow = clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
484 clrBarDkShadow = clrBtnDkShadow = ::GetSysColor(COLOR_3DDKSHADOW);
485 clrBarLight = clrBtnLight = ::GetSysColor(COLOR_3DLIGHT);
486 clrBarHilite = clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT);
487 clrBarText = clrBtnText = ::GetSysColor(COLOR_BTNTEXT);
488 clrGrayedText = ::GetSysColor(COLOR_GRAYTEXT);
489 clrWindowFrame = ::GetSysColor(COLOR_WINDOWFRAME);
491 clrHilite = ::GetSysColor(COLOR_HIGHLIGHT);
492 clrTextHilite = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
494 clrBarWindow = clrWindow = ::GetSysColor(COLOR_WINDOW);
495 clrWindowText = ::GetSysColor(COLOR_WINDOWTEXT);
497 clrCaptionText = ::GetSysColor(COLOR_CAPTIONTEXT);
498 clrMenuText = ::GetSysColor(COLOR_MENUTEXT);
500 clrActiveCaption = ::GetSysColor(COLOR_ACTIVECAPTION);
501 clrInactiveCaption = ::GetSysColor(COLOR_INACTIVECAPTION);
503 clrActiveCaptionGradient = ::GetSysColor(COLOR_GRADIENTACTIVECAPTION);
504 clrInactiveCaptionGradient = ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
506 clrActiveBorder = ::GetSysColor(COLOR_ACTIVEBORDER);
507 clrInactiveBorder = ::GetSysColor(COLOR_INACTIVEBORDER);
509 clrInactiveCaptionText = ::GetSysColor(COLOR_INACTIVECAPTIONTEXT);
511 if (m_bIsBlackHighContrast)
513 clrHotLinkNormalText = clrWindowText;
514 clrHotLinkHoveredText = clrWindowText;
515 clrHotLinkVisitedText = clrWindowText;
517 else
519 clrHotLinkNormalText = ::GetSysColor(COLOR_HOTLIGHT);
520 clrHotLinkHoveredText = RGB(0, 0, 255); // Bright blue
521 clrHotLinkVisitedText = RGB(128, 0, 128); // Violet
524 hbrBtnShadow = ::GetSysColorBrush(COLOR_BTNSHADOW);
525 ENSURE(hbrBtnShadow != NULL);
527 hbrBtnHilite = ::GetSysColorBrush(COLOR_BTNHIGHLIGHT);
528 ENSURE(hbrBtnHilite != NULL);
530 hbrWindow = ::GetSysColorBrush(COLOR_WINDOW);
531 ENSURE(hbrWindow != NULL);
533 brBtnFace.DeleteObject();
534 brBtnFace.CreateSolidBrush(clrBtnFace);
536 brBarFace.DeleteObject();
537 brBarFace.CreateSolidBrush(clrBarFace);
539 brActiveCaption.DeleteObject();
540 brActiveCaption.CreateSolidBrush(clrActiveCaption);
542 brInactiveCaption.DeleteObject();
543 brInactiveCaption.CreateSolidBrush(clrInactiveCaption);
545 brHilite.DeleteObject();
546 brHilite.CreateSolidBrush(clrHilite);
548 brBlack.DeleteObject();
549 brBlack.CreateSolidBrush(clrBtnDkShadow);
551 brWindow.DeleteObject();
552 brWindow.CreateSolidBrush(clrWindow);
554 penHilite.DeleteObject();
555 penHilite.CreatePen(PS_SOLID, 1, afxGlobalData.clrHilite);
557 penBarFace.DeleteObject();
558 penBarFace.CreatePen(PS_SOLID, 1, afxGlobalData.clrBarFace);
560 penBarShadow.DeleteObject();
561 penBarShadow.CreatePen(PS_SOLID, 1, afxGlobalData.clrBarShadow);
563 if (brLight.GetSafeHandle())
565 brLight.DeleteObject();
568 if (m_nBitsPerPixel > 8)
570 COLORREF clrLight = RGB(GetRValue(clrBtnFace) +((GetRValue(clrBtnHilite) - GetRValue(clrBtnFace)) / 2 ),
571 GetGValue(clrBtnFace) +((GetGValue(clrBtnHilite) - GetGValue(clrBtnFace)) / 2),
572 GetBValue(clrBtnFace) +((GetBValue(clrBtnHilite) - GetBValue(clrBtnFace)) / 2));
574 brLight.CreateSolidBrush(clrLight);
576 else
578 HBITMAP hbmGray = CreateDitherBitmap(dc.GetSafeHdc());
579 ENSURE(hbmGray != NULL);
581 CBitmap bmp;
582 bmp.Attach(hbmGray);
584 brLight.CreatePatternBrush(&bmp);
587 // CMenuImages::CleanUp();
588 // CDockingManager::m_bSDParamsModified = TRUE;
591 BOOL AFX_GLOBAL_DATA::SetMenuFont(LPLOGFONT lpLogFont, BOOL bHorz)
593 ENSURE(lpLogFont != NULL);
595 if (bHorz)
597 // Create regular font:
598 fontRegular.DeleteObject();
599 if (!fontRegular.CreateFontIndirect(lpLogFont))
601 ASSERT(FALSE);
602 return FALSE;
605 // Create underline font:
606 lpLogFont->lfUnderline = TRUE;
607 fontUnderline.DeleteObject();
608 fontUnderline.CreateFontIndirect(lpLogFont);
609 lpLogFont->lfUnderline = FALSE;
611 // Create bold font(used in the default menu items):
612 long lSavedWeight = lpLogFont->lfWeight;
613 lpLogFont->lfWeight = 700;
615 fontBold.DeleteObject();
616 BOOL bResult = fontBold.CreateFontIndirect(lpLogFont);
618 lpLogFont->lfWeight = lSavedWeight; // Restore weight
620 if (!bResult)
622 ASSERT(FALSE);
623 return FALSE;
626 else // Vertical font
628 fontVert.DeleteObject();
629 if (!fontVert.CreateFontIndirect(lpLogFont))
631 ASSERT(FALSE);
632 return FALSE;
636 UpdateTextMetrics();
637 return TRUE;
640 void AFX_GLOBAL_DATA::UpdateTextMetrics()
642 CWindowDC dc(NULL);
644 CFont* pOldFont = dc.SelectObject(&fontRegular);
645 ENSURE(pOldFont != NULL);
647 TEXTMETRIC tm;
648 dc.GetTextMetrics(&tm);
650 int nExtra = tm.tmHeight < 15 ? 2 : 5;
652 m_nTextHeightHorz = tm.tmHeight + nExtra;
653 m_nTextWidthHorz = tm.tmMaxCharWidth + nExtra;
655 dc.SelectObject(&fontVert);
656 dc.GetTextMetrics(&tm);
658 nExtra = tm.tmHeight < 15 ? 2 : 5;
660 m_nTextHeightVert = tm.tmHeight + nExtra;
661 m_nTextWidthVert = tm.tmMaxCharWidth + nExtra;
663 dc.SelectObject(pOldFont);
666 HBITMAP AFX_GLOBAL_DATA::CreateDitherBitmap(HDC hDC)
668 struct // BITMAPINFO with 16 colors
670 BITMAPINFOHEADER bmiHeader;
671 RGBQUAD bmiColors[16];
673 bmi;
674 memset(&bmi, 0, sizeof(bmi));
676 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
677 bmi.bmiHeader.biWidth = 8;
678 bmi.bmiHeader.biHeight = 8;
679 bmi.bmiHeader.biPlanes = 1;
680 bmi.bmiHeader.biBitCount = 1;
681 bmi.bmiHeader.biCompression = BI_RGB;
683 COLORREF clr = afxGlobalData.clrBtnFace;
685 bmi.bmiColors[0].rgbBlue = GetBValue(clr);
686 bmi.bmiColors[0].rgbGreen = GetGValue(clr);
687 bmi.bmiColors[0].rgbRed = GetRValue(clr);
689 clr = ::GetSysColor(COLOR_BTNHIGHLIGHT);
690 bmi.bmiColors[1].rgbBlue = GetBValue(clr);
691 bmi.bmiColors[1].rgbGreen = GetGValue(clr);
692 bmi.bmiColors[1].rgbRed = GetRValue(clr);
694 // initialize the brushes
695 long patGray[8];
696 for (int i = 0; i < 8; i++)
697 patGray[i] = (i & 1) ? 0xAAAA5555L : 0x5555AAAAL;
699 HBITMAP hbm = CreateDIBitmap(hDC, &bmi.bmiHeader, CBM_INIT, (LPBYTE)patGray, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS);
700 return hbm;
703 ITaskbarList* AFX_GLOBAL_DATA::GetITaskbarList()
705 // Backward-compatibility wrapper
706 CWinApp* pApp = AfxGetApp();
707 if (pApp != NULL)
709 return pApp->GetITaskbarList();
712 return NULL;
715 ITaskbarList3* AFX_GLOBAL_DATA::GetITaskbarList3()
717 // Backward-compatibility wrapper
718 CWinApp* pApp = AfxGetApp();
719 if (pApp != NULL)
721 return pApp->GetITaskbarList3();
724 return NULL;
727 void AFX_GLOBAL_DATA::CleanUp()
729 if (brLight.GetSafeHandle())
731 brLight.DeleteObject();
734 // cleanup fonts:
735 fontRegular.DeleteObject();
736 fontBold.DeleteObject();
737 fontUnderline.DeleteObject();
738 fontVert.DeleteObject();
739 fontVertCaption.DeleteObject();
740 fontTooltip.DeleteObject();
742 if (m_bBufferedPaintInited)
744 BufferedPaintUnInit();
745 m_bBufferedPaintInited = FALSE;
748 if (m_hinstDwmapiDLL != NULL)
750 ::FreeLibrary(m_hinstDwmapiDLL);
751 m_hinstDwmapiDLL = NULL;
754 m_bEnableAccessibility = FALSE;
757 void ControlBarCleanUp()
759 if (afxGlobalData.m_bInitialized)
761 afxGlobalData.CleanUp();
764 // afxMenuHash.CleanUp();
766 // CMFCToolBar::CleanUpImages();
767 // CMenuImages::CleanUp();
769 // if (GetCmdMgr() != NULL)
770 // {
771 // GetCmdMgr()->CleanUp();
772 // }
774 // CKeyboardManager::CleanUp();
776 // Destroy visualization manager:
777 // CMFCVisualManager::DestroyInstance(TRUE /* bAutoDestroyOnly */);
778 // CMFCVisualManagerOffice2007::CleanStyle();
781 #ifdef _AFXDLL
782 void AfxGlobalsAddRef()
784 InterlockedIncrement(&g_dwAfxGlobalDataRef);
787 void AfxGlobalsRelease()
789 InterlockedDecrement(&g_dwAfxGlobalDataRef);
790 if (g_dwAfxGlobalDataRef == 0)
792 ControlBarCleanUp();
795 #endif
797 BOOL AFX_GLOBAL_DATA::DrawParentBackground(CWnd* pWnd, CDC* pDC, LPRECT rectClip)
799 ASSERT_VALID(pDC);
800 ASSERT_VALID(pWnd);
802 BOOL bRes = FALSE;
804 CRgn rgn;
805 if (rectClip != NULL)
807 rgn.CreateRectRgnIndirect(rectClip);
808 pDC->SelectClipRgn(&rgn);
811 CWnd* pParent = pWnd->GetParent();
812 ASSERT_VALID(pParent);
814 // In Windows XP, we need to call DrawThemeParentBackground function to implement
815 // transparent controls
816 bRes = DrawThemeParentBackground(pWnd->GetSafeHwnd(), pDC->GetSafeHdc(), rectClip) == S_OK;
818 if (!bRes)
820 CPoint pt(0, 0);
821 pWnd->MapWindowPoints(pParent, &pt, 1);
822 pt = pDC->OffsetWindowOrg(pt.x, pt.y);
824 bRes = (BOOL) pParent->SendMessage(WM_ERASEBKGND, (WPARAM)pDC->m_hDC);
826 pDC->SetWindowOrg(pt.x, pt.y);
829 pDC->SelectClipRgn(NULL);
831 return bRes;
834 CFrameWnd* AFX_CDECL AFXGetParentFrame(const CWnd* pWnd)
836 if (pWnd->GetSafeHwnd() == NULL)
838 return NULL;
840 ASSERT_VALID(pWnd);
842 const CWnd* pParentWnd = pWnd;
844 while (pParentWnd != NULL)
846 // if (pParentWnd->IsKindOf(RUNTIME_CLASS(CPaneFrameWnd)))
847 //// {
848 // CPaneFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST(CPaneFrameWnd, pParentWnd);
849 // pParentWnd = pMiniFrame->GetParent();
850 // }
851 // else
853 pParentWnd = pParentWnd->GetParent();
856 if (pParentWnd == NULL)
858 return NULL;
861 if (pParentWnd->IsFrameWnd())
863 return(CFrameWnd*)pParentWnd;
867 return NULL;
870 COLORREF AFX_GLOBAL_DATA::GetColor(int nColor)
872 switch(nColor)
874 case COLOR_BTNFACE: return clrBtnFace;
875 case COLOR_BTNSHADOW: return clrBtnShadow;
876 case COLOR_3DDKSHADOW: return clrBtnDkShadow;
877 case COLOR_3DLIGHT: return clrBtnLight;
878 case COLOR_BTNHIGHLIGHT: return clrBtnHilite;
879 case COLOR_BTNTEXT: return clrBtnText;
880 case COLOR_GRAYTEXT: return clrGrayedText;
881 case COLOR_WINDOWFRAME: return clrWindowFrame;
883 case COLOR_HIGHLIGHT: return clrHilite;
884 case COLOR_HIGHLIGHTTEXT: return clrTextHilite;
886 case COLOR_WINDOW: return clrWindow;
887 case COLOR_WINDOWTEXT: return clrWindowText;
889 case COLOR_CAPTIONTEXT: return clrCaptionText;
890 case COLOR_MENUTEXT: return clrMenuText;
892 case COLOR_ACTIVECAPTION: return clrActiveCaption;
893 case COLOR_INACTIVECAPTION: return clrInactiveCaption;
895 case COLOR_ACTIVEBORDER: return clrActiveBorder;
896 case COLOR_INACTIVEBORDER: return clrInactiveBorder;
898 case COLOR_INACTIVECAPTIONTEXT: return clrInactiveCaptionText;
901 return ::GetSysColor(nColor);
904 BOOL AFX_GLOBAL_DATA::SetLayeredAttrib(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)
906 return(::SetLayeredWindowAttributes(hwnd, crKey, bAlpha, dwFlags));
909 void AFX_GLOBAL_DATA::EnableAccessibilitySupport(BOOL bEnable/* = TRUE*/)
911 m_bEnableAccessibility = bEnable;
914 CString AFX_GLOBAL_DATA::RegisterWindowClass(LPCTSTR lpszClassNamePrefix)
916 ENSURE(lpszClassNamePrefix != NULL);
918 // Register a new window class:
919 HINSTANCE hInst = AfxGetInstanceHandle();
920 UINT uiClassStyle = CS_DBLCLKS;
921 HCURSOR hCursor = ::LoadCursor(NULL, IDC_ARROW);
922 HBRUSH hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
924 CString strClassName;
925 strClassName.Format(_T("%s:%x:%x:%x:%x"), lpszClassNamePrefix, (UINT_PTR)hInst, uiClassStyle, (UINT_PTR)hCursor, (UINT_PTR)hbrBackground);
927 // See if the class already exists:
928 WNDCLASS wndcls;
929 if (::GetClassInfo(hInst, strClassName, &wndcls))
931 // Already registered, assert everything is good:
932 ASSERT(wndcls.style == uiClassStyle);
934 else
936 // Otherwise we need to register a new class:
937 wndcls.style = uiClassStyle;
938 wndcls.lpfnWndProc = ::DefWindowProc;
939 wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
940 wndcls.hInstance = hInst;
941 wndcls.hIcon = NULL;
942 wndcls.hCursor = hCursor;
943 wndcls.hbrBackground = hbrBackground;
944 wndcls.lpszMenuName = NULL;
945 wndcls.lpszClassName = strClassName;
947 if (!AfxRegisterClass(&wndcls))
949 AfxThrowResourceException();
953 return strClassName;
956 BOOL AFX_GLOBAL_DATA::ExcludeTag(CString& strBuffer, LPCTSTR lpszTag, CString& strTag, BOOL bIsCharsList /* = FALSE*/)
958 const int iBufLen = strBuffer.GetLength();
960 CString strTagStart = _T("<");
961 strTagStart += lpszTag;
962 strTagStart += _T(">");
964 const int iTagStartLen = strTagStart.GetLength();
966 int iStart = -1;
968 int iIndexStart = strBuffer.Find(strTagStart);
969 if (iIndexStart < 0)
971 return FALSE;
974 iStart = iIndexStart + iTagStartLen;
976 CString strTagEnd = _T("</");
977 strTagEnd += lpszTag;
978 strTagEnd += _T('>');
980 const int iTagEndLen = strTagEnd.GetLength();
982 int iIndexEnd = -1;
983 int nBalanse = 1;
984 for (int i = iStart; i < iBufLen - iTagEndLen + 1; i ++)
986 if (strBuffer [i] != '<')
988 continue;
991 if (i < iBufLen - iTagStartLen && _tcsncmp(strBuffer.Mid(i), strTagStart, iTagStartLen) == 0)
993 i += iTagStartLen - 1;
994 nBalanse ++;
995 continue;
998 if (_tcsncmp(strBuffer.Mid(i), strTagEnd, iTagEndLen) == 0)
1000 nBalanse --;
1001 if (nBalanse == 0)
1003 iIndexEnd = i;
1004 break;
1007 i += iTagEndLen - 1;
1011 if (iIndexEnd == -1 || iStart > iIndexEnd)
1013 return FALSE;
1016 strTag = strBuffer.Mid(iStart, iIndexEnd - iStart);
1017 strTag.TrimLeft();
1018 strTag.TrimRight();
1020 strBuffer.Delete(iIndexStart, iIndexEnd + iTagEndLen - iIndexStart);
1022 if (bIsCharsList)
1024 if (strTag.GetLength() > 1 && strTag [0] == _T('\"'))
1026 strTag = strTag.Mid(1, strTag.GetLength() - 2);
1029 strTag.Replace(_T("\\t"), _T("\t"));
1030 strTag.Replace(_T("\\n"), _T("\n"));
1031 strTag.Replace(_T("\\r"), _T("\r"));
1032 strTag.Replace(_T("\\b"), _T("\b"));
1033 strTag.Replace(_T("LT"), _T("<"));
1034 strTag.Replace(_T("GT"), _T(">"));
1035 strTag.Replace(_T("AMP"), _T("&"));
1038 return TRUE;
1041 BOOL AFX_GLOBAL_DATA::IsDwmCompositionEnabled()
1043 // It appears that DwmIsCompositionEnabled can fail if called and
1044 // then called again after a very short time, so use a static var
1045 // so the last obtained value is returned if the method fails.
1046 static BOOL bEnabled = FALSE;
1047 DwmIsCompositionEnabled(&bEnabled);
1048 return bEnabled;
1051 BOOL AFX_GLOBAL_DATA::DrawTextOnGlass(HTHEME hTheme, CDC* pDC, int iPartId, int iStateId, CString strText, CRect rect, DWORD dwFlags, int nGlowSize, COLORREF clrText)
1053 if (hTheme == NULL || !IsDwmCompositionEnabled())
1055 pDC->DrawText(strText, rect, dwFlags);
1056 return FALSE;
1059 CComBSTR bstmp = (LPCTSTR)strText;
1061 wchar_t* wbuf = new wchar_t[bstmp.Length() + 1];
1062 wcscpy_s(wbuf, bstmp.Length() + 1, bstmp);
1064 DTTOPTS dto;
1065 memset(&dto, 0, sizeof(DTTOPTS));
1066 dto.dwSize = sizeof(DTTOPTS);
1067 dto.dwFlags = DTT_COMPOSITED;
1069 if (nGlowSize > 0)
1071 dto.dwFlags |= DTT_GLOWSIZE;
1072 dto.iGlowSize = nGlowSize;
1075 if (clrText != (COLORREF)-1)
1077 dto.dwFlags |= DTT_TEXTCOLOR;
1078 dto.crText = clrText;
1081 DrawThemeTextEx(hTheme, pDC->GetSafeHdc(), iPartId, iStateId, wbuf, -1, dwFlags, rect, &dto);
1083 delete [] wbuf;
1085 return TRUE;
1088 HCURSOR AFX_GLOBAL_DATA::GetHandCursor()
1090 if (m_hcurHand == NULL)
1092 #pragma warning(push)
1093 #pragma warning(disable: 4302) // 'type cast' : truncation from 'LPSTR' to 'WORD'
1094 m_hcurHand = ::LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_HAND));
1095 #pragma warning(pop)
1098 return m_hcurHand;
1101 BOOL AFX_GLOBAL_DATA::Resume()
1103 if (m_bEnableAccessibility)
1105 EnableAccessibilitySupport();
1108 // CMFCVisualManagerOffice2007::Style style = CMFCVisualManagerOffice2007::GetStyle();
1109 // CMFCVisualManagerOffice2007::CleanStyle ();
1111 // if (CMFCVisualManager::m_pRTIDefault != NULL)
1112 // {
1113 // CMFCVisualManagerOffice2007::SetStyle(style);
1114 // CMFCVisualManager::SetDefaultManager (CMFCVisualManager::m_pRTIDefault);
1115 // }
1117 return TRUE;
1120 BOOL AFX_GLOBAL_DATA::GetNonClientMetrics (NONCLIENTMETRICS& info)
1122 struct AFX_OLDNONCLIENTMETRICS
1124 UINT cbSize;
1125 int iBorderWidth;
1126 int iScrollWidth;
1127 int iScrollHeight;
1128 int iCaptionWidth;
1129 int iCaptionHeight;
1130 LOGFONT lfCaptionFont;
1131 int iSmCaptionWidth;
1132 int iSmCaptionHeight;
1133 LOGFONT lfSmCaptionFont;
1134 int iMenuWidth;
1135 int iMenuHeight;
1136 LOGFONT lfMenuFont;
1137 LOGFONT lfStatusFont;
1138 LOGFONT lfMessageFont;
1141 if (!bIsWindows7)
1143 info.cbSize = sizeof(AFX_OLDNONCLIENTMETRICS);
1146 return ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, info.cbSize, &info, 0);
1150 BOOL AFXAPI AfxIsExtendedFrameClass(CWnd* pWnd)
1152 ENSURE( pWnd );
1153 #if 0
1154 if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWndEx)))
1156 return TRUE;
1158 if (pWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))
1160 return TRUE;
1162 if (pWnd->IsKindOf(RUNTIME_CLASS(COleIPFrameWndEx)))
1164 return TRUE;
1166 if (pWnd->IsKindOf(RUNTIME_CLASS(COleDocIPFrameWndEx)))
1168 return TRUE;
1170 if (pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWndEx)))
1172 return TRUE;
1174 #endif
1175 return FALSE;
1179 BOOL AFXAPI AfxIsMFCToolBar(CWnd* pWnd)
1181 ENSURE( pWnd );
1182 // if (pWnd->IsKindOf(RUNTIME_CLASS(CMFCToolBar)))
1183 // {
1184 // return TRUE;
1185 // }
1186 return FALSE;
1189 HRESULT AFX_GLOBAL_DATA::ShellCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv)
1191 return SHCreateItemFromParsingName(pszPath, pbc, riid, ppv);
1194 #else
1196 static const CString strOfficeFontName = _T("Tahoma");
1197 static const CString strOffice2007FontName = _T("Segoe UI");
1198 static const CString strDefaultFontName = _T("MS Sans Serif");
1199 static const CString strVertFontName = _T("Arial");
1200 static const CString strMarlettFontName = _T("Marlett");
1202 HINSTANCE AFX_GLOBAL_DATA::m_hinstD2DDLL = NULL;
1203 HINSTANCE AFX_GLOBAL_DATA::m_hinstDWriteDLL = NULL;
1205 ID2D1Factory* AFX_GLOBAL_DATA::m_pDirect2dFactory = NULL;
1206 IDWriteFactory* AFX_GLOBAL_DATA::m_pWriteFactory = NULL;
1207 IWICImagingFactory* AFX_GLOBAL_DATA::m_pWicFactory = NULL;
1209 D2D1MAKEROTATEMATRIX AFX_GLOBAL_DATA::m_pfD2D1MakeRotateMatrix = NULL;
1211 BOOL AFX_GLOBAL_DATA::m_bD2DInitialized = FALSE;
1213 CMemDC::CMemDC(CDC& dc, CWnd* pWnd) :
1214 m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL)
1216 ASSERT_VALID(pWnd);
1218 pWnd->GetClientRect(m_rect);
1220 m_rect.right += pWnd->GetScrollPos(SB_HORZ);
1221 m_rect.bottom += pWnd->GetScrollPos(SB_VERT);
1223 if (afxGlobalData.m_pfBeginBufferedPaint != NULL && afxGlobalData.m_pfEndBufferedPaint != NULL)
1225 HDC hdcPaint = NULL;
1227 if (!afxGlobalData.m_bBufferedPaintInited && afxGlobalData.m_pfBufferedPaintInit != NULL && afxGlobalData.m_pfBufferedPaintUnInit != NULL)
1229 afxGlobalData.m_pfBufferedPaintInit();
1230 afxGlobalData.m_bBufferedPaintInited = TRUE;
1233 m_hBufferedPaint = (*afxGlobalData.m_pfBeginBufferedPaint)(dc.GetSafeHdc(), m_rect, AFX_BPBF_TOPDOWNDIB, NULL, &hdcPaint);
1235 if (m_hBufferedPaint != NULL && hdcPaint != NULL)
1237 m_bMemDC = TRUE;
1238 m_dcMem.Attach(hdcPaint);
1241 else
1243 if (m_bUseMemoryDC && m_dcMem.CreateCompatibleDC(&m_dc) && m_bmp.CreateCompatibleBitmap(&m_dc, m_rect.Width(), m_rect.Height()))
1245 //-------------------------------------------------------------
1246 // Off-screen DC successfully created. Better paint to it then!
1247 //-------------------------------------------------------------
1248 m_bMemDC = TRUE;
1249 m_pOldBmp = m_dcMem.SelectObject(&m_bmp);
1254 CMemDC::CMemDC(CDC& dc, const CRect& rect) :
1255 m_dc(dc), m_bMemDC(FALSE), m_hBufferedPaint(NULL), m_pOldBmp(NULL), m_rect(rect)
1257 ASSERT(!m_rect.IsRectEmpty());
1259 if (afxGlobalData.m_pfBeginBufferedPaint != NULL && afxGlobalData.m_pfEndBufferedPaint != NULL)
1261 HDC hdcPaint = NULL;
1263 if (!afxGlobalData.m_bBufferedPaintInited && afxGlobalData.m_pfBufferedPaintInit != NULL && afxGlobalData.m_pfBufferedPaintUnInit != NULL)
1265 afxGlobalData.m_pfBufferedPaintInit();
1266 afxGlobalData.m_bBufferedPaintInited = TRUE;
1269 m_hBufferedPaint = (*afxGlobalData.m_pfBeginBufferedPaint)(dc.GetSafeHdc(), m_rect, AFX_BPBF_TOPDOWNDIB, NULL, &hdcPaint);
1271 if (m_hBufferedPaint != NULL && hdcPaint != NULL)
1273 m_bMemDC = TRUE;
1274 m_dcMem.Attach(hdcPaint);
1277 else
1279 if (m_bUseMemoryDC && m_dcMem.CreateCompatibleDC(&m_dc) && m_bmp.CreateCompatibleBitmap(&m_dc, m_rect.Width(), m_rect.Height()))
1281 //-------------------------------------------------------------
1282 // Off-screen DC successfully created. Better paint to it then!
1283 //-------------------------------------------------------------
1284 m_bMemDC = TRUE;
1285 m_pOldBmp = m_dcMem.SelectObject(&m_bmp);
1290 CMemDC::~CMemDC()
1292 if (m_hBufferedPaint != NULL)
1294 m_dcMem.Detach();
1295 (*afxGlobalData.m_pfEndBufferedPaint)(m_hBufferedPaint, TRUE);
1297 else if (m_bMemDC)
1299 //--------------------------------------
1300 // Copy the results to the on-screen DC:
1301 //--------------------------------------
1302 CRect rectClip;
1303 int nClipType = m_dc.GetClipBox(rectClip);
1305 if (nClipType != NULLREGION)
1307 if (nClipType != SIMPLEREGION)
1309 rectClip = m_rect;
1312 m_dc.BitBlt(rectClip.left, rectClip.top, rectClip.Width(), rectClip.Height(), &m_dcMem, rectClip.left, rectClip.top, SRCCOPY);
1315 m_dcMem.SelectObject(m_pOldBmp);
1319 static int CALLBACK FontFamalyProcFonts(const LOGFONT FAR* lplf, const TEXTMETRIC FAR* /*lptm*/, ULONG /*ulFontType*/, LPARAM lParam)
1321 ENSURE(lplf != NULL);
1322 ENSURE(lParam != NULL);
1324 CString strFont = lplf->lfFaceName;
1325 return strFont.CollateNoCase((LPCTSTR) lParam) == 0 ? 0 : 1;
1328 /////////////////////////////////////////////////////////////////////////////
1329 // DLL Load Helper
1331 inline HMODULE AfxLoadSystemLibraryUsingFullPath(_In_z_ const WCHAR *pszLibrary)
1333 WCHAR wszLoadPath[MAX_PATH+1];
1334 if (::GetSystemDirectoryW(wszLoadPath, _countof(wszLoadPath)) == 0)
1336 return NULL;
1339 if (wszLoadPath[wcslen(wszLoadPath)-1] != L'\\')
1341 if (wcscat_s(wszLoadPath, _countof(wszLoadPath), L"\\") != 0)
1343 return NULL;
1347 if (wcscat_s(wszLoadPath, _countof(wszLoadPath), pszLibrary) != 0)
1349 return NULL;
1352 return(::AfxCtxLoadLibraryW(wszLoadPath));
1355 /////////////////////////////////////////////////////////////////////////////
1356 // Cached system metrics, etc
1357 AFX_GLOBAL_DATA afxGlobalData;
1359 #ifdef _AFXDLL
1360 // Reference count on global data
1361 DWORD g_dwAfxGlobalDataRef = 0;
1362 #endif
1364 // Initialization code
1365 AFX_GLOBAL_DATA::AFX_GLOBAL_DATA()
1367 // Detect the kind of OS:
1368 OSVERSIONINFO osvi;
1369 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
1371 ::GetVersionEx(&osvi);
1373 bIsRemoteSession = GetSystemMetrics(SM_REMOTESESSION);
1375 bIsWindowsVista = (osvi.dwMajorVersion >= 6);
1376 bIsWindows7 = (osvi.dwMajorVersion == 6) && (osvi.dwMinorVersion >= 1) || (osvi.dwMajorVersion > 6) ;
1377 bDisableAero = FALSE;
1379 m_bIsRibbonImageScale = TRUE;
1381 // Cached system values(updated in CWnd::OnSysColorChange)
1382 hbrBtnShadow = NULL;
1383 hbrBtnHilite = NULL;
1384 hbrWindow = NULL;
1386 UpdateSysColors();
1388 m_hinstUXThemeDLL = ::AfxCtxLoadLibraryW(L"UxTheme.dll");
1389 if (m_hinstUXThemeDLL != NULL)
1391 m_pfDrawThemeBackground = (DRAWTHEMEPARENTBACKGROUND)::GetProcAddress(m_hinstUXThemeDLL, "DrawThemeParentBackground");
1392 m_pfDrawThemeTextEx = (DRAWTHEMETEXTEX)::GetProcAddress(m_hinstUXThemeDLL, "DrawThemeTextEx");
1394 m_pfBufferedPaintInit = (BUFFEREDPAINTINIT)::GetProcAddress(m_hinstUXThemeDLL, "BufferedPaintInit");
1395 m_pfBufferedPaintUnInit = (BUFFEREDPAINTUNINIT)::GetProcAddress(m_hinstUXThemeDLL, "BufferedPaintUnInit");
1397 m_pfBeginBufferedPaint = (BEGINBUFFEREDPAINT)::GetProcAddress(m_hinstUXThemeDLL, "BeginBufferedPaint");
1398 m_pfEndBufferedPaint = (ENDBUFFEREDPAINT)::GetProcAddress(m_hinstUXThemeDLL, "EndBufferedPaint");
1400 else
1402 m_pfDrawThemeBackground = NULL;
1403 m_pfDrawThemeTextEx = NULL;
1405 m_pfBufferedPaintInit = NULL;
1406 m_pfBufferedPaintUnInit = NULL;
1408 m_pfBeginBufferedPaint = NULL;
1409 m_pfEndBufferedPaint = NULL;
1412 m_hinstDwmapiDLL = AfxLoadSystemLibraryUsingFullPath(L"dwmapi.dll");
1413 if (m_hinstDwmapiDLL != NULL)
1415 m_pfDwmExtendFrameIntoClientArea = (DWMEXTENDFRAMEINTOCLIENTAREA)::GetProcAddress(m_hinstDwmapiDLL, "DwmExtendFrameIntoClientArea");
1416 m_pfDwmDefWindowProc = (DWMDEFWINDOWPROC) ::GetProcAddress(m_hinstDwmapiDLL, "DwmDefWindowProc");
1417 m_pfDwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED)::GetProcAddress(m_hinstDwmapiDLL, "DwmIsCompositionEnabled");
1419 else
1421 m_pfDwmExtendFrameIntoClientArea = NULL;
1422 m_pfDwmDefWindowProc = NULL;
1423 m_pfDwmIsCompositionEnabled = NULL;
1426 m_hcurStretch = NULL;
1427 m_hcurStretchVert = NULL;
1428 m_hcurHand = NULL;
1429 m_hcurSizeAll = NULL;
1430 m_hiconTool = NULL;
1431 m_hiconLink = NULL;
1432 m_hiconColors = NULL;
1433 m_hcurMoveTab = NULL;
1434 m_hcurNoMoveTab = NULL;
1436 m_bUseSystemFont = FALSE;
1437 m_bInSettingChange = FALSE;
1439 UpdateFonts();
1440 OnSettingChange();
1442 m_bIsRTL = FALSE;
1443 m_bBufferedPaintInited = FALSE;
1445 m_nDragFrameThicknessFloat = 4; // pixels
1446 m_nDragFrameThicknessDock = 3; // pixels
1448 m_nAutoHideToolBarSpacing = 14; // pixels
1449 m_nAutoHideToolBarMargin = 4; // pixels
1451 m_nCoveredMainWndClientAreaPercent = 50; // percents
1453 m_nMaxToolTipWidth = -1;
1454 m_bIsBlackHighContrast = FALSE;
1455 m_bIsWhiteHighContrast = FALSE;
1457 m_bUseBuiltIn32BitIcons = TRUE;
1459 m_bComInitialized = FALSE;
1461 m_pTaskbarList = NULL;
1462 m_pTaskbarList3 = NULL;
1463 m_bTaskBarInterfacesAvailable = TRUE;
1465 EnableAccessibilitySupport();
1468 AFX_GLOBAL_DATA::~AFX_GLOBAL_DATA()
1470 CleanUp();
1473 void AFX_GLOBAL_DATA::UpdateFonts()
1475 CWindowDC dc(NULL);
1476 m_dblRibbonImageScale = dc.GetDeviceCaps(LOGPIXELSX) / 96.0f;
1478 if (m_dblRibbonImageScale > 1. && m_dblRibbonImageScale < 1.1)
1480 m_dblRibbonImageScale = 1.;
1483 if (fontRegular.GetSafeHandle() != NULL)
1485 ::DeleteObject(fontRegular.Detach());
1488 if (fontTooltip.GetSafeHandle() != NULL)
1490 ::DeleteObject(fontTooltip.Detach());
1493 if (fontBold.GetSafeHandle() != NULL)
1495 ::DeleteObject(fontBold.Detach());
1498 if (fontDefaultGUIBold.GetSafeHandle() != NULL)
1500 ::DeleteObject(fontDefaultGUIBold.Detach());
1503 if (fontUnderline.GetSafeHandle() != NULL)
1505 ::DeleteObject(fontUnderline.Detach());
1508 if (fontDefaultGUIUnderline.GetSafeHandle() != NULL)
1510 ::DeleteObject(fontDefaultGUIUnderline.Detach());
1513 if (fontVert.GetSafeHandle() != NULL)
1515 ::DeleteObject(fontVert.Detach());
1518 if (fontVertCaption.GetSafeHandle() != NULL)
1520 ::DeleteObject(fontVertCaption.Detach());
1523 if (fontMarlett.GetSafeHandle() != NULL)
1525 ::DeleteObject(fontMarlett.Detach());
1528 if (fontSmall.GetSafeHandle() != NULL)
1530 ::DeleteObject(fontSmall.Detach());
1533 // Initialize fonts:
1535 NONCLIENTMETRICS info;
1536 info.cbSize = sizeof(info);
1537 GetNonClientMetrics (info);
1539 LOGFONT lf;
1540 memset(&lf, 0, sizeof(LOGFONT));
1542 lf.lfCharSet = (BYTE) GetTextCharsetInfo(dc.GetSafeHdc(), NULL, 0);
1544 lf.lfHeight = info.lfMenuFont.lfHeight;
1545 lf.lfWeight = info.lfMenuFont.lfWeight;
1546 lf.lfItalic = info.lfMenuFont.lfItalic;
1548 //------------------
1549 // Adjust font size:
1550 //------------------
1551 int nFontHeight = lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight;
1552 if (nFontHeight <= 12)
1554 nFontHeight = 11;
1556 else
1558 nFontHeight--;
1561 lf.lfHeight = (lf.lfHeight < 0) ? -nFontHeight : nFontHeight;
1563 // Check if we should use system font
1564 lstrcpy(lf.lfFaceName, info.lfMenuFont.lfFaceName);
1566 BOOL fUseSystemFont = m_bUseSystemFont || (info.lfMenuFont.lfCharSet > SYMBOL_CHARSET);
1567 if (!fUseSystemFont)
1569 // Check for "Segoe UI" or "Tahoma" font existance:
1570 if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamalyProcFonts, (LPARAM)(LPCTSTR) strOffice2007FontName) == 0)
1572 // Found! Use MS Office 2007 font!
1573 lstrcpy(lf.lfFaceName, strOffice2007FontName);
1574 lf.lfQuality = 5 /*CLEARTYPE_QUALITY*/;
1576 else if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamalyProcFonts, (LPARAM)(LPCTSTR) strOfficeFontName) == 0)
1578 // Found! Use MS Office font!
1579 lstrcpy(lf.lfFaceName, strOfficeFontName);
1581 else
1583 // Not found. Use default font:
1584 lstrcpy(lf.lfFaceName, strDefaultFontName);
1588 fontRegular.CreateFontIndirect(&lf);
1590 // Create small font:
1591 LONG lfHeightSaved = lf.lfHeight;
1593 lf.lfHeight = (long)((1. + abs(lf.lfHeight)) * 2 / 3);
1594 if (lfHeightSaved < 0)
1596 lf.lfHeight = -lf.lfHeight;
1599 fontSmall.CreateFontIndirect(&lf);
1600 lf.lfHeight = lfHeightSaved;
1602 // Create tooltip font:
1603 NONCLIENTMETRICS ncm;
1604 ncm.cbSize = sizeof(ncm);
1605 GetNonClientMetrics (ncm);
1607 lf.lfItalic = ncm.lfStatusFont.lfItalic;
1608 lf.lfWeight = ncm.lfStatusFont.lfWeight;
1609 fontTooltip.CreateFontIndirect(&lf);
1611 lf.lfItalic = info.lfMenuFont.lfItalic;
1612 lf.lfWeight = info.lfMenuFont.lfWeight;
1614 // Create "underline" font:
1615 lf.lfUnderline = TRUE;
1616 fontUnderline.CreateFontIndirect(&lf);
1617 lf.lfUnderline = FALSE;
1619 // Create bold font:
1620 lf.lfWeight = FW_BOLD;
1621 fontBold.CreateFontIndirect(&lf);
1623 // Create Marlett font:
1624 BYTE bCharSet = lf.lfCharSet;
1625 lf.lfWeight = info.lfMenuFont.lfWeight;
1626 lf.lfCharSet = SYMBOL_CHARSET;
1627 lf.lfWeight = 0;
1628 lf.lfHeight = ::GetSystemMetrics(SM_CYMENUCHECK) - 1;
1629 lstrcpy(lf.lfFaceName, strMarlettFontName);
1631 fontMarlett.CreateFontIndirect(&lf);
1632 lf.lfCharSet = bCharSet; // Restore charset
1634 // Create vertical font:
1635 CFont font;
1636 if (font.CreateStockObject(DEFAULT_GUI_FONT))
1638 if (font.GetLogFont(&lf) != 0)
1640 lf.lfOrientation = 900;
1641 lf.lfEscapement = 2700;
1643 lf.lfHeight = info.lfMenuFont.lfHeight;
1644 lf.lfWeight = info.lfMenuFont.lfWeight;
1645 lf.lfItalic = info.lfMenuFont.lfItalic;
1648 lstrcpy(lf.lfFaceName, strVertFontName);
1651 fontVert.CreateFontIndirect(&lf);
1653 lf.lfEscapement = 900;
1654 fontVertCaption.CreateFontIndirect(&lf);
1658 // Create dialog underline and bold fonts:
1659 CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
1660 ASSERT_VALID(pDefaultGUIFont);
1661 pDefaultGUIFont->GetLogFont(&lf);
1663 lf.lfUnderline = TRUE;
1664 fontDefaultGUIUnderline.CreateFontIndirect(&lf);
1665 lf.lfUnderline = FALSE;
1667 lf.lfWeight = FW_BOLD;
1668 fontDefaultGUIBold.CreateFontIndirect(&lf);
1670 UpdateTextMetrics();
1672 #if 0
1673 // Notify toolbars about font changing:
1674 for (POSITION posTlb = afxAllToolBars.GetHeadPosition(); posTlb != NULL;)
1676 CMFCToolBar* pToolBar = (CMFCToolBar*) afxAllToolBars.GetNext(posTlb);
1677 ENSURE(pToolBar != NULL);
1679 if (CWnd::FromHandlePermanent(pToolBar->m_hWnd) != NULL)
1681 ASSERT_VALID(pToolBar);
1682 pToolBar->OnGlobalFontsChanged();
1685 #endif
1688 static BOOL CALLBACK InfoEnumProc( HMONITOR hMonitor, HDC /*hdcMonitor*/, LPRECT /*lprcMonitor*/, LPARAM dwData)
1690 CRect* pRect = (CRect*) dwData;
1692 MONITORINFO mi;
1693 mi.cbSize = sizeof(MONITORINFO);
1695 if (GetMonitorInfo(hMonitor, &mi))
1697 CRect rectMon = mi.rcWork;
1699 pRect->left = min(pRect->left, rectMon.left);
1700 pRect->right = max(pRect->right, rectMon.right);
1701 pRect->top = min(pRect->top, rectMon.top);
1702 pRect->bottom = max(pRect->bottom, rectMon.bottom);
1705 return TRUE;
1708 void AFX_GLOBAL_DATA::OnSettingChange()
1710 m_bInSettingChange = TRUE;
1712 m_sizeSmallIcon.cx = ::GetSystemMetrics(SM_CXSMICON);
1713 m_sizeSmallIcon.cy = ::GetSystemMetrics(SM_CYSMICON);
1715 m_rectVirtual.SetRectEmpty();
1717 if (!EnumDisplayMonitors(NULL, NULL, InfoEnumProc, (LPARAM) &m_rectVirtual))
1719 ::SystemParametersInfo(SPI_GETWORKAREA, 0, &m_rectVirtual, 0);
1722 // Get system menu animation type:
1723 m_bMenuAnimation = FALSE;
1724 m_bMenuFadeEffect = FALSE;
1726 if (!bIsRemoteSession)
1728 ::SystemParametersInfo(SPI_GETMENUANIMATION, 0, &m_bMenuAnimation, 0);
1730 if (m_bMenuAnimation)
1732 ::SystemParametersInfo(SPI_GETMENUFADE, 0, &m_bMenuFadeEffect, 0);
1736 m_nShellAutohideBars = 0;
1737 m_bRefreshAutohideBars = TRUE;
1739 ::SystemParametersInfo(SPI_GETMENUUNDERLINES, 0, &m_bSysUnderlineKeyboardShortcuts, 0);
1740 m_bUnderlineKeyboardShortcuts = m_bSysUnderlineKeyboardShortcuts;
1742 m_bInSettingChange = FALSE;
1745 void AFX_GLOBAL_DATA::UpdateSysColors()
1747 m_bIsBlackHighContrast = ::GetSysColor(COLOR_3DLIGHT) == RGB(255, 255, 255) && ::GetSysColor(COLOR_3DFACE) == RGB(0, 0, 0);
1748 m_bIsWhiteHighContrast = ::GetSysColor(COLOR_3DDKSHADOW) == RGB(0, 0, 0) && ::GetSysColor(COLOR_3DFACE) == RGB(255, 255, 255);
1750 CWindowDC dc(NULL);
1751 m_nBitsPerPixel = dc.GetDeviceCaps(BITSPIXEL);
1753 clrBarFace = clrBtnFace = ::GetSysColor(COLOR_BTNFACE);
1754 clrBarShadow = clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW);
1755 clrBarDkShadow = clrBtnDkShadow = ::GetSysColor(COLOR_3DDKSHADOW);
1756 clrBarLight = clrBtnLight = ::GetSysColor(COLOR_3DLIGHT);
1757 clrBarHilite = clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT);
1758 clrBarText = clrBtnText = ::GetSysColor(COLOR_BTNTEXT);
1759 clrGrayedText = ::GetSysColor(COLOR_GRAYTEXT);
1760 clrWindowFrame = ::GetSysColor(COLOR_WINDOWFRAME);
1762 clrHilite = ::GetSysColor(COLOR_HIGHLIGHT);
1763 clrTextHilite = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
1765 clrBarWindow = clrWindow = ::GetSysColor(COLOR_WINDOW);
1766 clrWindowText = ::GetSysColor(COLOR_WINDOWTEXT);
1768 clrCaptionText = ::GetSysColor(COLOR_CAPTIONTEXT);
1769 clrMenuText = ::GetSysColor(COLOR_MENUTEXT);
1771 clrActiveCaption = ::GetSysColor(COLOR_ACTIVECAPTION);
1772 clrInactiveCaption = ::GetSysColor(COLOR_INACTIVECAPTION);
1774 clrActiveCaptionGradient = ::GetSysColor(COLOR_GRADIENTACTIVECAPTION);
1775 clrInactiveCaptionGradient = ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
1777 clrActiveBorder = ::GetSysColor(COLOR_ACTIVEBORDER);
1778 clrInactiveBorder = ::GetSysColor(COLOR_INACTIVEBORDER);
1780 clrInactiveCaptionText = ::GetSysColor(COLOR_INACTIVECAPTIONTEXT);
1782 if (m_bIsBlackHighContrast)
1784 clrHotLinkNormalText = clrWindowText;
1785 clrHotLinkHoveredText = clrWindowText;
1786 clrHotLinkVisitedText = clrWindowText;
1788 else
1790 clrHotLinkNormalText = ::GetSysColor(COLOR_HOTLIGHT);
1791 clrHotLinkHoveredText = RGB(0, 0, 255); // Bright blue
1792 clrHotLinkVisitedText = RGB(128, 0, 128); // Violet
1795 hbrBtnShadow = ::GetSysColorBrush(COLOR_BTNSHADOW);
1796 ENSURE(hbrBtnShadow != NULL);
1798 hbrBtnHilite = ::GetSysColorBrush(COLOR_BTNHIGHLIGHT);
1799 ENSURE(hbrBtnHilite != NULL);
1801 hbrWindow = ::GetSysColorBrush(COLOR_WINDOW);
1802 ENSURE(hbrWindow != NULL);
1804 brBtnFace.DeleteObject();
1805 brBtnFace.CreateSolidBrush(clrBtnFace);
1807 brBarFace.DeleteObject();
1808 brBarFace.CreateSolidBrush(clrBarFace);
1810 brActiveCaption.DeleteObject();
1811 brActiveCaption.CreateSolidBrush(clrActiveCaption);
1813 brInactiveCaption.DeleteObject();
1814 brInactiveCaption.CreateSolidBrush(clrInactiveCaption);
1816 brHilite.DeleteObject();
1817 brHilite.CreateSolidBrush(clrHilite);
1819 brBlack.DeleteObject();
1820 brBlack.CreateSolidBrush(clrBtnDkShadow);
1822 brWindow.DeleteObject();
1823 brWindow.CreateSolidBrush(clrWindow);
1825 penHilite.DeleteObject();
1826 penHilite.CreatePen(PS_SOLID, 1, afxGlobalData.clrHilite);
1828 penBarFace.DeleteObject();
1829 penBarFace.CreatePen(PS_SOLID, 1, afxGlobalData.clrBarFace);
1831 penBarShadow.DeleteObject();
1832 penBarShadow.CreatePen(PS_SOLID, 1, afxGlobalData.clrBarShadow);
1834 if (brLight.GetSafeHandle())
1836 brLight.DeleteObject();
1839 if (m_nBitsPerPixel > 8)
1841 COLORREF clrLight = RGB(GetRValue(clrBtnFace) +((GetRValue(clrBtnHilite) - GetRValue(clrBtnFace)) / 2 ),
1842 GetGValue(clrBtnFace) +((GetGValue(clrBtnHilite) - GetGValue(clrBtnFace)) / 2),
1843 GetBValue(clrBtnFace) +((GetBValue(clrBtnHilite) - GetBValue(clrBtnFace)) / 2));
1845 brLight.CreateSolidBrush(clrLight);
1847 else
1849 HBITMAP hbmGray = CreateDitherBitmap(dc.GetSafeHdc());
1850 ENSURE(hbmGray != NULL);
1852 CBitmap bmp;
1853 bmp.Attach(hbmGray);
1855 brLight.CreatePatternBrush(&bmp);
1858 // CMenuImages::CleanUp();
1859 // CDockingManager::m_bSDParamsModified = TRUE;
1862 BOOL AFX_GLOBAL_DATA::SetMenuFont(LPLOGFONT lpLogFont, BOOL bHorz)
1864 ENSURE(lpLogFont != NULL);
1866 if (bHorz)
1868 // Create regular font:
1869 fontRegular.DeleteObject();
1870 if (!fontRegular.CreateFontIndirect(lpLogFont))
1872 ASSERT(FALSE);
1873 return FALSE;
1876 // Create underline font:
1877 lpLogFont->lfUnderline = TRUE;
1878 fontUnderline.DeleteObject();
1879 fontUnderline.CreateFontIndirect(lpLogFont);
1880 lpLogFont->lfUnderline = FALSE;
1882 // Create bold font(used in the default menu items):
1883 long lSavedWeight = lpLogFont->lfWeight;
1884 lpLogFont->lfWeight = 700;
1886 fontBold.DeleteObject();
1887 BOOL bResult = fontBold.CreateFontIndirect(lpLogFont);
1889 lpLogFont->lfWeight = lSavedWeight; // Restore weight
1891 if (!bResult)
1893 ASSERT(FALSE);
1894 return FALSE;
1897 else // Vertical font
1899 fontVert.DeleteObject();
1900 if (!fontVert.CreateFontIndirect(lpLogFont))
1902 ASSERT(FALSE);
1903 return FALSE;
1907 UpdateTextMetrics();
1908 return TRUE;
1911 void AFX_GLOBAL_DATA::UpdateTextMetrics()
1913 CWindowDC dc(NULL);
1915 CFont* pOldFont = dc.SelectObject(&fontRegular);
1916 ENSURE(pOldFont != NULL);
1918 TEXTMETRIC tm;
1919 dc.GetTextMetrics(&tm);
1921 int nExtra = tm.tmHeight < 15 ? 2 : 5;
1923 m_nTextHeightHorz = tm.tmHeight + nExtra;
1924 m_nTextWidthHorz = tm.tmMaxCharWidth + nExtra;
1926 dc.SelectObject(&fontVert);
1927 dc.GetTextMetrics(&tm);
1929 nExtra = tm.tmHeight < 15 ? 2 : 5;
1931 m_nTextHeightVert = tm.tmHeight + nExtra;
1932 m_nTextWidthVert = tm.tmMaxCharWidth + nExtra;
1934 dc.SelectObject(pOldFont);
1937 HBITMAP AFX_GLOBAL_DATA::CreateDitherBitmap(HDC hDC)
1939 struct // BITMAPINFO with 16 colors
1941 BITMAPINFOHEADER bmiHeader;
1942 RGBQUAD bmiColors[16];
1944 bmi;
1945 memset(&bmi, 0, sizeof(bmi));
1947 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1948 bmi.bmiHeader.biWidth = 8;
1949 bmi.bmiHeader.biHeight = 8;
1950 bmi.bmiHeader.biPlanes = 1;
1951 bmi.bmiHeader.biBitCount = 1;
1952 bmi.bmiHeader.biCompression = BI_RGB;
1954 COLORREF clr = afxGlobalData.clrBtnFace;
1956 bmi.bmiColors[0].rgbBlue = GetBValue(clr);
1957 bmi.bmiColors[0].rgbGreen = GetGValue(clr);
1958 bmi.bmiColors[0].rgbRed = GetRValue(clr);
1960 clr = ::GetSysColor(COLOR_BTNHIGHLIGHT);
1961 bmi.bmiColors[1].rgbBlue = GetBValue(clr);
1962 bmi.bmiColors[1].rgbGreen = GetGValue(clr);
1963 bmi.bmiColors[1].rgbRed = GetRValue(clr);
1965 // initialize the brushes
1966 long patGray[8];
1967 for (int i = 0; i < 8; i++)
1968 patGray[i] = (i & 1) ? 0xAAAA5555L : 0x5555AAAAL;
1970 HBITMAP hbm = CreateDIBitmap(hDC, &bmi.bmiHeader, CBM_INIT, (LPBYTE)patGray, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS);
1971 return hbm;
1974 #if (WINVER >= 0x0601)
1975 ITaskbarList* AFX_GLOBAL_DATA::GetITaskbarList()
1977 HRESULT hr = S_OK;
1979 if (!bIsWindows7 || !m_bTaskBarInterfacesAvailable)
1981 return NULL;
1984 if (m_pTaskbarList != NULL)
1986 return m_pTaskbarList;
1989 if (!m_bComInitialized)
1991 hr = CoInitialize(NULL);
1992 if (SUCCEEDED(hr))
1994 m_bComInitialized = TRUE;
1998 if (SUCCEEDED(hr))
2000 hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList));
2003 ASSERT(SUCCEEDED(hr));
2004 return m_pTaskbarList;
2007 ITaskbarList3* AFX_GLOBAL_DATA::GetITaskbarList3()
2009 HRESULT hr = S_OK;
2011 if (!bIsWindows7 || !m_bTaskBarInterfacesAvailable)
2013 return NULL;
2016 if (m_pTaskbarList3 != NULL)
2018 return m_pTaskbarList3;
2021 if (!m_bComInitialized)
2023 hr = CoInitialize(NULL);
2024 if (SUCCEEDED(hr))
2026 m_bComInitialized = TRUE;
2030 if (SUCCEEDED(hr))
2032 hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList3));
2035 ASSERT(SUCCEEDED(hr));
2036 return m_pTaskbarList3;
2039 void AFX_GLOBAL_DATA::ReleaseTaskBarRefs()
2041 m_bTaskBarInterfacesAvailable = FALSE;
2043 if (m_pTaskbarList != NULL)
2045 RELEASE(m_pTaskbarList);
2046 m_pTaskbarList = NULL;
2049 if (m_pTaskbarList3 != NULL)
2051 RELEASE(m_pTaskbarList3);
2052 m_pTaskbarList3 = NULL;
2055 #endif
2057 void AFX_GLOBAL_DATA::CleanUp()
2059 if (brLight.GetSafeHandle())
2061 brLight.DeleteObject();
2064 // cleanup fonts:
2065 fontRegular.DeleteObject();
2066 fontBold.DeleteObject();
2067 fontUnderline.DeleteObject();
2068 fontVert.DeleteObject();
2069 fontVertCaption.DeleteObject();
2070 fontTooltip.DeleteObject();
2072 ReleaseTaskBarRefs();
2073 ReleaseD2DRefs();
2075 if (m_bBufferedPaintInited && m_pfBufferedPaintUnInit != NULL)
2077 m_pfBufferedPaintUnInit();
2078 m_bBufferedPaintInited = FALSE;
2081 if (m_hinstUXThemeDLL != NULL)
2083 ::FreeLibrary(m_hinstUXThemeDLL);
2084 m_hinstUXThemeDLL = NULL;
2087 if (m_hinstDwmapiDLL != NULL)
2089 ::FreeLibrary(m_hinstDwmapiDLL);
2090 m_hinstDwmapiDLL = NULL;
2093 m_bEnableAccessibility = FALSE;
2095 if (m_bComInitialized)
2097 CoUninitialize();
2098 m_bComInitialized = FALSE;
2102 void ControlBarCleanUp()
2104 afxGlobalData.CleanUp();
2106 // afxMenuHash.CleanUp();
2108 // CMFCToolBar::CleanUpImages();
2109 // CMenuImages::CleanUp();
2111 // if (GetCmdMgr() != NULL)
2112 // {
2113 // GetCmdMgr()->CleanUp();
2114 // }
2116 // CKeyboardManager::CleanUp();
2118 // Destroy visualization manager:
2119 // CMFCVisualManager::DestroyInstance(TRUE /* bAutoDestroyOnly */);
2120 // CMFCVisualManagerOffice2007::CleanStyle();
2123 #ifdef _AFXDLL
2124 void AfxGlobalsAddRef()
2126 g_dwAfxGlobalDataRef++;
2129 void AfxGlobalsRelease()
2131 g_dwAfxGlobalDataRef--;
2132 if (g_dwAfxGlobalDataRef == 0)
2134 ControlBarCleanUp();
2137 #endif
2139 BOOL AFX_GLOBAL_DATA::DrawParentBackground(CWnd* pWnd, CDC* pDC, LPRECT rectClip)
2141 ASSERT_VALID(pDC);
2142 ASSERT_VALID(pWnd);
2144 BOOL bRes = FALSE;
2146 CRgn rgn;
2147 if (rectClip != NULL)
2149 rgn.CreateRectRgnIndirect(rectClip);
2150 pDC->SelectClipRgn(&rgn);
2153 CWnd* pParent = pWnd->GetParent();
2154 ASSERT_VALID(pParent);
2156 // In Windows XP, we need to call DrawThemeParentBackground function to implement
2157 // transparent controls
2158 if (m_pfDrawThemeBackground != NULL)
2160 bRes = (*m_pfDrawThemeBackground)(pWnd->GetSafeHwnd(), pDC->GetSafeHdc(), rectClip) == S_OK;
2163 if (!bRes)
2165 CPoint pt(0, 0);
2166 pWnd->MapWindowPoints(pParent, &pt, 1);
2167 pt = pDC->OffsetWindowOrg(pt.x, pt.y);
2169 bRes = (BOOL) pParent->SendMessage(WM_ERASEBKGND, (WPARAM)pDC->m_hDC);
2171 pDC->SetWindowOrg(pt.x, pt.y);
2174 pDC->SelectClipRgn(NULL);
2176 return bRes;
2179 CFrameWnd* AFXGetParentFrame(const CWnd* pWnd)
2181 if (pWnd->GetSafeHwnd() == NULL)
2183 return NULL;
2185 ASSERT_VALID(pWnd);
2187 const CWnd* pParentWnd = pWnd;
2189 while (pParentWnd != NULL)
2191 // if (pParentWnd->IsKindOf(RUNTIME_CLASS(CPaneFrameWnd)))
2192 //// {
2193 // CPaneFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST(CPaneFrameWnd, pParentWnd);
2194 // pParentWnd = pMiniFrame->GetParent();
2195 // }
2196 // else
2198 pParentWnd = pParentWnd->GetParent();
2201 if (pParentWnd == NULL)
2203 return NULL;
2206 if (pParentWnd->IsFrameWnd())
2208 return(CFrameWnd*)pParentWnd;
2212 return NULL;
2215 COLORREF AFX_GLOBAL_DATA::GetColor(int nColor)
2217 switch(nColor)
2219 case COLOR_BTNFACE: return clrBtnFace;
2220 case COLOR_BTNSHADOW: return clrBtnShadow;
2221 case COLOR_3DDKSHADOW: return clrBtnDkShadow;
2222 case COLOR_3DLIGHT: return clrBtnLight;
2223 case COLOR_BTNHIGHLIGHT: return clrBtnHilite;
2224 case COLOR_BTNTEXT: return clrBtnText;
2225 case COLOR_GRAYTEXT: return clrGrayedText;
2226 case COLOR_WINDOWFRAME: return clrWindowFrame;
2228 case COLOR_HIGHLIGHT: return clrHilite;
2229 case COLOR_HIGHLIGHTTEXT: return clrTextHilite;
2231 case COLOR_WINDOW: return clrWindow;
2232 case COLOR_WINDOWTEXT: return clrWindowText;
2234 case COLOR_CAPTIONTEXT: return clrCaptionText;
2235 case COLOR_MENUTEXT: return clrMenuText;
2237 case COLOR_ACTIVECAPTION: return clrActiveCaption;
2238 case COLOR_INACTIVECAPTION: return clrInactiveCaption;
2240 case COLOR_ACTIVEBORDER: return clrActiveBorder;
2241 case COLOR_INACTIVEBORDER: return clrInactiveBorder;
2243 case COLOR_INACTIVECAPTIONTEXT: return clrInactiveCaptionText;
2246 return ::GetSysColor(nColor);
2249 BOOL AFX_GLOBAL_DATA::SetLayeredAttrib(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)
2251 return(::SetLayeredWindowAttributes(hwnd, crKey, bAlpha, dwFlags));
2254 void AFX_GLOBAL_DATA::EnableAccessibilitySupport(BOOL bEnable/* = TRUE*/)
2256 m_bEnableAccessibility = bEnable;
2259 CString AFX_GLOBAL_DATA::RegisterWindowClass(LPCTSTR lpszClassNamePrefix)
2261 ENSURE(lpszClassNamePrefix != NULL);
2263 // Register a new window class:
2264 HINSTANCE hInst = AfxGetInstanceHandle();
2265 UINT uiClassStyle = CS_DBLCLKS;
2266 HCURSOR hCursor = ::LoadCursor(NULL, IDC_ARROW);
2267 HBRUSH hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2269 CString strClassName;
2270 strClassName.Format(_T("%s:%x:%x:%x:%x"), lpszClassNamePrefix, (UINT_PTR)hInst, uiClassStyle, (UINT_PTR)hCursor, (UINT_PTR)hbrBackground);
2272 // See if the class already exists:
2273 WNDCLASS wndcls;
2274 if (::GetClassInfo(hInst, strClassName, &wndcls))
2276 // Already registered, assert everything is good:
2277 ASSERT(wndcls.style == uiClassStyle);
2279 else
2281 // Otherwise we need to register a new class:
2282 wndcls.style = uiClassStyle;
2283 wndcls.lpfnWndProc = ::DefWindowProc;
2284 wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
2285 wndcls.hInstance = hInst;
2286 wndcls.hIcon = NULL;
2287 wndcls.hCursor = hCursor;
2288 wndcls.hbrBackground = hbrBackground;
2289 wndcls.lpszMenuName = NULL;
2290 wndcls.lpszClassName = strClassName;
2292 if (!AfxRegisterClass(&wndcls))
2294 AfxThrowResourceException();
2298 return strClassName;
2301 BOOL AFX_GLOBAL_DATA::ExcludeTag(CString& strBuffer, LPCTSTR lpszTag, CString& strTag, BOOL bIsCharsList /* = FALSE*/)
2303 const int iBufLen = strBuffer.GetLength();
2305 CString strTagStart = _T("<");
2306 strTagStart += lpszTag;
2307 strTagStart += _T(">");
2309 const int iTagStartLen = strTagStart.GetLength();
2311 int iStart = -1;
2313 int iIndexStart = strBuffer.Find(strTagStart);
2314 if (iIndexStart < 0)
2316 return FALSE;
2319 iStart = iIndexStart + iTagStartLen;
2321 CString strTagEnd = _T("</");
2322 strTagEnd += lpszTag;
2323 strTagEnd += _T('>');
2325 const int iTagEndLen = strTagEnd.GetLength();
2327 int iIndexEnd = -1;
2328 int nBalanse = 1;
2329 for (int i = iStart; i < iBufLen - iTagEndLen + 1; i ++)
2331 if (strBuffer [i] != '<')
2333 continue;
2336 if (i < iBufLen - iTagStartLen && _tcsncmp(strBuffer.Mid(i), strTagStart, iTagStartLen) == 0)
2338 i += iTagStartLen - 1;
2339 nBalanse ++;
2340 continue;
2343 if (_tcsncmp(strBuffer.Mid(i), strTagEnd, iTagEndLen) == 0)
2345 nBalanse --;
2346 if (nBalanse == 0)
2348 iIndexEnd = i;
2349 break;
2352 i += iTagEndLen - 1;
2356 if (iIndexEnd == -1 || iStart > iIndexEnd)
2358 return FALSE;
2361 strTag = strBuffer.Mid(iStart, iIndexEnd - iStart);
2362 strTag.TrimLeft();
2363 strTag.TrimRight();
2365 strBuffer.Delete(iIndexStart, iIndexEnd + iTagEndLen - iIndexStart);
2367 if (bIsCharsList)
2369 if (strTag.GetLength() > 1 && strTag [0] == _T('\"'))
2371 strTag = strTag.Mid(1, strTag.GetLength() - 2);
2374 strTag.Replace(_T("\\t"), _T("\t"));
2375 strTag.Replace(_T("\\n"), _T("\n"));
2376 strTag.Replace(_T("\\r"), _T("\r"));
2377 strTag.Replace(_T("\\b"), _T("\b"));
2378 strTag.Replace(_T("LT"), _T("<"));
2379 strTag.Replace(_T("GT"), _T(">"));
2380 strTag.Replace(_T("AMP"), _T("&"));
2383 return TRUE;
2386 BOOL AFX_GLOBAL_DATA::DwmExtendFrameIntoClientArea(HWND hWnd, AFX_MARGINS* pMargins)
2388 if (m_pfDwmExtendFrameIntoClientArea == NULL)
2390 return FALSE;
2393 HRESULT hres = (*m_pfDwmExtendFrameIntoClientArea)(hWnd, pMargins);
2394 return hres == S_OK;
2397 LRESULT AFX_GLOBAL_DATA::DwmDefWindowProc(HWND hWnd, UINT message, WPARAM wp, LPARAM lp)
2399 if (m_pfDwmDefWindowProc == NULL)
2401 return(LRESULT)-1;
2404 LRESULT lres = 0;
2405 (*m_pfDwmDefWindowProc)(hWnd, message, wp, lp, &lres);
2407 return lres;
2410 BOOL AFX_GLOBAL_DATA::DwmIsCompositionEnabled()
2412 if (m_pfDwmIsCompositionEnabled == NULL || bDisableAero)
2414 return FALSE;
2417 BOOL bEnabled = FALSE;
2419 (*m_pfDwmIsCompositionEnabled)(&bEnabled);
2420 return bEnabled;
2423 BOOL AFX_GLOBAL_DATA::DrawTextOnGlass(HTHEME hTheme, CDC* pDC, int iPartId, int iStateId, CString strText, CRect rect, DWORD dwFlags, int nGlowSize, COLORREF clrText)
2425 //---- bits used in dwFlags of DTTOPTS ----
2426 #define AFX_DTT_TEXTCOLOR (1UL << 0) // crText has been specified
2427 #define AFX_DTT_BORDERCOLOR (1UL << 1) // crBorder has been specified
2428 #define AFX_DTT_SHADOWCOLOR (1UL << 2) // crShadow has been specified
2429 #define AFX_DTT_SHADOWTYPE (1UL << 3) // iTextShadowType has been specified
2430 #define AFX_DTT_SHADOWOFFSET (1UL << 4) // ptShadowOffset has been specified
2431 #define AFX_DTT_BORDERSIZE (1UL << 5) // nBorderSize has been specified
2432 #define AFX_DTT_FONTPROP (1UL << 6) // iFontPropId has been specified
2433 #define AFX_DTT_COLORPROP (1UL << 7) // iColorPropId has been specified
2434 #define AFX_DTT_STATEID (1UL << 8) // IStateId has been specified
2435 #define AFX_DTT_CALCRECT (1UL << 9) // Use pRect as and in/out parameter
2436 #define AFX_DTT_APPLYOVERLAY (1UL << 10) // fApplyOverlay has been specified
2437 #define AFX_DTT_GLOWSIZE (1UL << 11) // iGlowSize has been specified
2438 #define AFX_DTT_CALLBACK (1UL << 12) // pfnDrawTextCallback has been specified
2439 #define AFX_DTT_COMPOSITED (1UL << 13) // Draws text with antialiased alpha(needs a DIB section)
2441 if (hTheme == NULL || m_pfDrawThemeTextEx == NULL || !DwmIsCompositionEnabled())
2443 pDC->DrawText(strText, rect, dwFlags);
2444 return FALSE;
2447 CComBSTR bstmp = (LPCTSTR)strText;
2449 wchar_t* wbuf = new wchar_t[bstmp.Length() + 1];
2450 wcscpy_s(wbuf, bstmp.Length() + 1, bstmp);
2452 AFX_DTTOPTS dto;
2453 memset(&dto, 0, sizeof(AFX_DTTOPTS));
2454 dto.dwSize = sizeof(AFX_DTTOPTS);
2455 dto.dwFlags = AFX_DTT_COMPOSITED;
2457 if (nGlowSize > 0)
2459 dto.dwFlags |= AFX_DTT_GLOWSIZE;
2460 dto.iGlowSize = nGlowSize;
2463 if (clrText != (COLORREF)-1)
2465 dto.dwFlags |= AFX_DTT_TEXTCOLOR;
2466 dto.crText = clrText;
2469 (*m_pfDrawThemeTextEx)(hTheme, pDC->GetSafeHdc(), iPartId, iStateId, wbuf, -1, dwFlags, rect, &dto);
2471 delete [] wbuf;
2473 return TRUE;
2476 HCURSOR AFX_GLOBAL_DATA::GetHandCursor()
2478 if (m_hcurHand == NULL)
2480 m_hcurHand = ::LoadCursorW(NULL, MAKEINTRESOURCEW(IDC_HAND));
2483 return m_hcurHand;
2486 BOOL AFX_GLOBAL_DATA::Resume()
2488 m_hinstUXThemeDLL = ::AfxCtxLoadLibraryW(L"UxTheme.dll");
2490 if (m_hinstUXThemeDLL != NULL)
2492 m_pfDrawThemeBackground = (DRAWTHEMEPARENTBACKGROUND)::GetProcAddress (m_hinstUXThemeDLL, "DrawThemeParentBackground");
2493 m_pfDrawThemeTextEx = (DRAWTHEMETEXTEX)::GetProcAddress (m_hinstUXThemeDLL, "DrawThemeTextEx");
2494 m_pfBeginBufferedPaint = (BEGINBUFFEREDPAINT)::GetProcAddress (m_hinstUXThemeDLL, "BeginBufferedPaint");
2495 m_pfEndBufferedPaint = (ENDBUFFEREDPAINT)::GetProcAddress (m_hinstUXThemeDLL, "EndBufferedPaint");
2497 else
2499 m_pfDrawThemeBackground = NULL;
2500 m_pfDrawThemeTextEx = NULL;
2501 m_pfBeginBufferedPaint = NULL;
2502 m_pfEndBufferedPaint = NULL;
2505 if (m_hinstDwmapiDLL != NULL)
2507 m_hinstDwmapiDLL = AfxLoadSystemLibraryUsingFullPath(L"dwmapi.dll");
2508 ENSURE(m_hinstDwmapiDLL != NULL);
2510 m_pfDwmExtendFrameIntoClientArea = (DWMEXTENDFRAMEINTOCLIENTAREA)::GetProcAddress (m_hinstDwmapiDLL, "DwmExtendFrameIntoClientArea");
2511 m_pfDwmDefWindowProc = (DWMDEFWINDOWPROC) ::GetProcAddress (m_hinstDwmapiDLL, "DwmDefWindowProc");
2512 m_pfDwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED)::GetProcAddress (m_hinstDwmapiDLL, "DwmIsCompositionEnabled");
2515 if (m_bEnableAccessibility)
2517 EnableAccessibilitySupport();
2520 // CMFCVisualManagerOffice2007::CleanStyle ();
2522 // if (CMFCVisualManager::m_pRTIDefault != NULL)
2523 // {
2524 // CMFCVisualManager::SetDefaultManager (CMFCVisualManager::m_pRTIDefault);
2525 // }
2527 return TRUE;
2530 BOOL AFX_GLOBAL_DATA::GetNonClientMetrics (NONCLIENTMETRICS& info)
2532 struct AFX_OLDNONCLIENTMETRICS
2534 UINT cbSize;
2535 int iBorderWidth;
2536 int iScrollWidth;
2537 int iScrollHeight;
2538 int iCaptionWidth;
2539 int iCaptionHeight;
2540 LOGFONT lfCaptionFont;
2541 int iSmCaptionWidth;
2542 int iSmCaptionHeight;
2543 LOGFONT lfSmCaptionFont;
2544 int iMenuWidth;
2545 int iMenuHeight;
2546 LOGFONT lfMenuFont;
2547 LOGFONT lfStatusFont;
2548 LOGFONT lfMessageFont;
2551 if (_AfxGetComCtlVersion() < MAKELONG(1, 6))
2553 info.cbSize = sizeof(AFX_OLDNONCLIENTMETRICS);
2556 return ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, info.cbSize, &info, 0);
2560 BOOL AFXAPI AfxIsExtendedFrameClass(CWnd* pWnd)
2562 ENSURE( pWnd );
2563 #if 0
2564 if (pWnd->IsKindOf(RUNTIME_CLASS(CFrameWndEx)))
2566 return TRUE;
2568 if (pWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWndEx)))
2570 return TRUE;
2572 if (pWnd->IsKindOf(RUNTIME_CLASS(COleIPFrameWndEx)))
2574 return TRUE;
2576 if (pWnd->IsKindOf(RUNTIME_CLASS(COleDocIPFrameWndEx)))
2578 return TRUE;
2580 if (pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWndEx)))
2582 return TRUE;
2584 #endif
2585 return FALSE;
2589 BOOL AFXAPI AfxIsMFCToolBar(CWnd* pWnd)
2591 ENSURE( pWnd );
2592 // if (pWnd->IsKindOf(RUNTIME_CLASS(CMFCToolBar)))
2593 // {
2594 // return TRUE;
2595 // }
2596 return FALSE;
2599 HRESULT AFX_GLOBAL_DATA::ShellCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv)
2601 static HMODULE hShellDll = AfxCtxLoadLibrary(_T("Shell32.dll"));
2602 ENSURE(hShellDll != NULL);
2604 typedef HRESULT (__stdcall *PFNSHCREATEITEMFROMPARSINGNAME)(
2605 PCWSTR,
2606 IBindCtx*,
2607 REFIID,
2608 void**
2611 PFNSHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName =
2612 (PFNSHCREATEITEMFROMPARSINGNAME)GetProcAddress(hShellDll, "SHCreateItemFromParsingName");
2613 if (pSHCreateItemFromParsingName == NULL)
2615 return E_FAIL;
2618 return (*pSHCreateItemFromParsingName)(pszPath, pbc, riid, ppv);
2621 BOOL AFX_GLOBAL_DATA::InitD2D(D2D1_FACTORY_TYPE d2dFactoryType, DWRITE_FACTORY_TYPE writeFactoryType)
2623 if (m_bD2DInitialized)
2625 return TRUE;
2628 HRESULT hr = S_OK;
2630 if (!m_bComInitialized)
2632 hr = CoInitialize(NULL);
2633 if (FAILED(hr))
2635 return FALSE;
2639 m_bComInitialized = TRUE;
2641 if ((m_hinstD2DDLL = AfxLoadSystemLibraryUsingFullPath(L"D2D1.dll")) == NULL)
2643 return FALSE;
2646 typedef HRESULT (WINAPI * D2D1CREATEFACTORY)(D2D1_FACTORY_TYPE factoryType, REFIID riid, CONST D2D1_FACTORY_OPTIONS *pFactoryOptions, void **ppIFactory);
2647 typedef HRESULT (WINAPI * DWRITECREATEFACTORY)(DWRITE_FACTORY_TYPE factoryType, REFIID riid, IUnknown **factory);
2649 D2D1CREATEFACTORY pfD2D1CreateFactory = (D2D1CREATEFACTORY)::GetProcAddress(m_hinstD2DDLL, "D2D1CreateFactory");
2650 if (pfD2D1CreateFactory != NULL)
2652 hr = (*pfD2D1CreateFactory)(d2dFactoryType, __uuidof(ID2D1Factory),
2653 NULL, reinterpret_cast<void **>(&m_pDirect2dFactory));
2654 if (FAILED(hr))
2656 m_pDirect2dFactory = NULL;
2657 return FALSE;
2661 m_pfD2D1MakeRotateMatrix = (D2D1MAKEROTATEMATRIX)::GetProcAddress(m_hinstD2DDLL, "D2D1MakeRotateMatrix");
2663 m_hinstDWriteDLL = AfxLoadSystemLibraryUsingFullPath(L"DWrite.dll");
2664 if (m_hinstDWriteDLL != NULL)
2666 DWRITECREATEFACTORY pfD2D1CreateFactory = (DWRITECREATEFACTORY)::GetProcAddress(m_hinstDWriteDLL, "DWriteCreateFactory");
2667 if (pfD2D1CreateFactory != NULL)
2669 hr = (*pfD2D1CreateFactory)(writeFactoryType, __uuidof(IDWriteFactory), (IUnknown**)&m_pWriteFactory);
2673 hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)&m_pWicFactory);
2675 m_bD2DInitialized = TRUE;
2676 return TRUE;
2679 void AFX_GLOBAL_DATA::ReleaseD2DRefs()
2681 if (!m_bD2DInitialized)
2683 return;
2686 if (m_pDirect2dFactory != NULL)
2688 m_pDirect2dFactory->Release();
2689 m_pDirect2dFactory = NULL;
2692 if (m_pWriteFactory != NULL)
2694 m_pWriteFactory->Release();
2695 m_pWriteFactory = NULL;
2698 if (m_pWicFactory != NULL)
2700 m_pWicFactory->Release();
2701 m_pWicFactory = NULL;
2704 if (m_hinstD2DDLL != NULL)
2706 ::FreeLibrary(m_hinstD2DDLL);
2709 if (m_hinstDWriteDLL != NULL)
2711 ::FreeLibrary(m_hinstDWriteDLL);
2714 m_bD2DInitialized = FALSE;
2717 #endif