~_AFX_TOOLBAR_TERM() { #ifndef _MAC AfxDeleteObject((HGDIOBJ*)&hDCMono); AfxDeleteObject((HGDIOBJ*)&hDCGlyphs); #endif AfxDeleteObject((HGDIOBJ*)&hbrDither); }
void GLOBAL_DATA::UpdateSysColors() { clrBtnFace = ::GetSysColor(COLOR_BTNFACE); clrBtnShadow = ::GetSysColor(COLOR_BTNSHADOW); clrBtnHilite = ::GetSysColor(COLOR_BTNHIGHLIGHT); clrBtnText = ::GetSysColor(COLOR_BTNTEXT); clrWindowFrame = ::GetSysColor(COLOR_WINDOWFRAME); AfxDeleteObject((HGDIOBJ*)&hbrBtnFace); AfxDeleteObject((HGDIOBJ*)&hbrBtnShadow); AfxDeleteObject((HGDIOBJ*)&hbrBtnHilite); AfxDeleteObject((HGDIOBJ*)&hbrWindowFrame); hbrBtnFace = ::CreateSolidBrush(clrBtnFace); ASSERT(hbrBtnFace != NULL); hbrBtnShadow = ::CreateSolidBrush(clrBtnShadow); ASSERT(hbrBtnShadow != NULL); hbrBtnHilite = ::CreateSolidBrush(clrBtnHilite); ASSERT(hbrBtnHilite != NULL); hbrWindowFrame = ::CreateSolidBrush(clrWindowFrame); ASSERT(hbrWindowFrame != NULL); AfxDeleteObject((HGDIOBJ*)&hpenBtnShadow); AfxDeleteObject((HGDIOBJ*)&hpenBtnHilite); AfxDeleteObject((HGDIOBJ*)&hpenBtnText); hpenBtnShadow = ::CreatePen(PS_SOLID, 0, clrBtnShadow); ASSERT(hpenBtnShadow != NULL); hpenBtnHilite = ::CreatePen(PS_SOLID, 0, clrBtnHilite); ASSERT(hpenBtnHilite != NULL); hpenBtnText = ::CreatePen(PS_SOLID, 0, clrBtnText); ASSERT(hpenBtnText != NULL); }
// Termination code AUX_DATA::~AUX_DATA() { AFX_BEGIN_DESTRUCTOR // clean up object we don't actually create AfxDeleteObject((HGDIOBJ*)&hbmMenuDot); AFX_END_DESTRUCTOR }
void CEditView::OnEndPrinting(CDC*, CPrintInfo*) { ASSERT_VALID(this); m_aPageStart.RemoveAll(); if (m_hMirrorFont != NULL && m_hPrinterFont == m_hMirrorFont) { AfxDeleteObject((HGDIOBJ*)&m_hMirrorFont); m_hPrinterFont = NULL; } }
CFlatToolbar::~CFlatToolbar() { #ifdef _MAC ASSERT(m_hDCGlyphs != NULL); VERIFY(::DeleteDC(m_hDCGlyphs)); ASSERT(m_hDCMono != NULL); VERIFY(::DeleteDC(m_hDCMono)); #endif AfxDeleteObject((HGDIOBJ*)&m_hbmImageWell); }
void CFlatToolbar::OnSysColorChange() { #ifdef _MAC CControlBar::OnSysColorChange(); ASSERT(hDCGlyphs != NULL); VERIFY(::DeleteDC(hDCGlyphs)); hDCGlyphs = ::CreateCompatibleDC(NULL); ASSERT(hDCMono != NULL); VERIFY(::DeleteDC(hDCMono)); hDCMono = ::CreateCompatibleDC(NULL); #endif // re-initialize global dither brush #ifndef _MAC HBITMAP hbmGray = ::CreateDitherBitmap(); #else HBITMAP hbmGray = ::CreateDitherBitmap(m_bMonochrome); #endif if (hbmGray != NULL) { HBRUSH hbrNew = ::CreatePatternBrush(hbmGray); if (hbrNew != NULL) { AfxDeleteObject((HGDIOBJ*)&hbrDither); // free old one hbrDither = hbrNew; } ::DeleteObject(hbmGray); } // re-color bitmap for toolbar if (m_hbmImageWell != NULL) { HBITMAP hbmNew; #ifndef _MAC hbmNew = LoadSysColorBitmap(m_hInstImageWell, m_hRsrcImageWell); #else hbmNew = LoadSysColorBitmap(m_hInstImageWell, m_hRsrcImageWell, m_hDCGlyphs, m_bMonochrome); #endif if (hbmNew != NULL) { ::DeleteObject(m_hbmImageWell); // free old one m_hbmImageWell = hbmNew; } } }
BOOL CFlatToolbar::PrepareDrawButton(DrawState& ds) { ASSERT(m_hbmImageWell != NULL); ASSERT(m_sizeButton.cx > 2 && m_sizeButton.cy > 2); // We need to kick-start the bitmap selection process. ds.hbmOldGlyphs = (HBITMAP)SelectObject(hDCGlyphs, m_hbmImageWell); ds.hbmMono = CreateBitmap(m_sizeButton.cx-2, m_sizeButton.cy-2, 1, 1, NULL); ds.hbmMonoOld = (HBITMAP)SelectObject(hDCMono, ds.hbmMono); if (ds.hbmOldGlyphs == NULL || ds.hbmMono == NULL || ds.hbmMonoOld == NULL) { TRACE0("Error: can't draw toolbar.\n"); AfxDeleteObject((HGDIOBJ*)&ds.hbmMono); return FALSE; } return TRUE; }
void AFX_TOOLTIP::OnPaint() { // get text of window TCHAR szText[256]; UINT nLen = GetWindowText(szText, _countof(szText)); // get client rectangle CRect rect; GetClientRect(rect); // setup DC for painting CPaintDC dc(this); HFONT hFontOld = NULL; if (afxData.hToolTipsFont != NULL) hFontOld = (HFONT)dc.SelectObject(afxData.hToolTipsFont); // determine correct colors for background & foreground COLORREF crInfoBack, crInfoFore; if (afxData.bWin4) { crInfoBack = GetSysColor(COLOR_INFOBK); crInfoFore = GetSysColor(COLOR_INFOTEXT); } else { crInfoBack = RGB(255, 255, 128); crInfoFore = RGB(0, 0, 0); } // paint background and text HBRUSH hBrush = ::CreateSolidBrush(crInfoBack); if (hBrush != NULL) ::FillRect(dc.m_hDC, &rect, hBrush); dc.SetBkMode(TRANSPARENT); TCHAR chSpace = ' '; CSize size = dc.GetTextExtent(&chSpace, 1); dc.SetTextColor(crInfoFore); dc.TextOut(size.cx, CY_BORDER, szText, nLen); // cleanup the DC if (hFontOld != NULL) dc.SelectObject(hFontOld); AfxDeleteObject((HGDIOBJ*)&hBrush); }
void CWinApp::SetDialogBkColor(COLORREF clrCtlBk, COLORREF clrCtlText) { if (!afxContextIsDLL) { _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); if (pThreadState->m_hHookOldCbtFilter == NULL) { pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT, _AfxCbtFilterHook, NULL, ::GetCurrentThreadId()); if (pThreadState->m_hHookOldCbtFilter == NULL) AfxThrowMemoryException(); } } // set up for grey backgrounds for dialogs _AFX_WIN_STATE* pWinState = _afxWinState; AfxDeleteObject((HGDIOBJ*)&pWinState->m_hDlgBkBrush); #ifdef _MAC // MFC's default gray color is available in the VGA palette but not in // the standard Mac 4- or 8-bit color tables, so we will remap it to // the closest available solid color. We also want to use 3DLIGHT or BTNFACE // as the background color rather than the darker gray that Win32 MFC uses. if (clrCtlBk == RGB(192, 192, 192)) { DWORD dwFlags; SystemParametersInfo(SPI_GET3D, 0, (LPVOID) &dwFlags, 0); UINT nColor = (dwFlags & F3D_OFFICE3D) ? COLOR_3DFACE : COLOR_3DLIGHT; HDC hdc = ::GetDC(NULL); clrCtlBk = GetNearestColor(hdc, GetSysColor(nColor)); ::ReleaseDC(NULL, hdc); } // save the requested background color pWinState->m_crDlgBkClr = clrCtlBk; #endif pWinState->m_hDlgBkBrush = ::CreateSolidBrush(clrCtlBk); pWinState->m_crDlgTextClr = clrCtlText; if (pWinState->m_hDlgBkBrush == NULL) AfxThrowResourceException(); }
BOOL CFlatToolbar::LoadBitmap(LPCTSTR lpszResourceName) { ASSERT_VALID(this); ASSERT(lpszResourceName != NULL); AfxDeleteObject((HGDIOBJ*)&m_hbmImageWell); // get rid of old one m_hInstImageWell = AfxFindResourceHandle(lpszResourceName, RT_BITMAP); if ((m_hRsrcImageWell = ::FindResource(m_hInstImageWell, lpszResourceName, RT_BITMAP)) == NULL) return FALSE; #ifndef _MAC m_hbmImageWell = LoadSysColorBitmap(m_hInstImageWell, m_hRsrcImageWell); #else m_hbmImageWell = LoadSysColorBitmap(m_hInstImageWell, m_hRsrcImageWell, m_hDCGlyphs, m_bMonochrome); #endif return (m_hbmImageWell != NULL); }
void CWinApp::SetDialogBkColor(COLORREF clrCtlBk, COLORREF clrCtlText) { if (!afxContextIsDLL) { _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); if (pThreadState->m_hHookOldCbtFilter == NULL) { pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT, _AfxCbtFilterHook, NULL, ::GetCurrentThreadId()); if (pThreadState->m_hHookOldCbtFilter == NULL) AfxThrowMemoryException(); } } // set up for gray backgrounds for dialogs _AFX_WIN_STATE* pWinState = _afxWinState; AfxDeleteObject((HGDIOBJ*)&pWinState->m_hDlgBkBrush); pWinState->m_hDlgBkBrush = ::CreateSolidBrush(clrCtlBk); pWinState->m_crDlgTextClr = clrCtlText; if (pWinState->m_hDlgBkBrush == NULL) AfxThrowResourceException(); }
~_AFX_EDITVIEW_TERM() { AfxDeleteObject((HGDIOBJ*)&hUnicodeFont); }
~_AFX_WINGDIX_TERM() { AfxDeleteObject((HGDIOBJ*)&halftoneBrush); }
// Termination code GLOBAL_DATA::~GLOBAL_DATA() { // cleanup standard brushes AfxDeleteObject((HGDIOBJ*)&hbrLtGray); AfxDeleteObject((HGDIOBJ*)&hbrDkGray); AfxDeleteObject((HGDIOBJ*)&hbrBtnFace); AfxDeleteObject((HGDIOBJ*)&hbrBtnShadow); AfxDeleteObject((HGDIOBJ*)&hbrBtnHilite); AfxDeleteObject((HGDIOBJ*)&hbrWindowFrame); // cleanup standard pens AfxDeleteObject((HGDIOBJ*)&hpenBtnShadow); AfxDeleteObject((HGDIOBJ*)&hpenBtnHilite); AfxDeleteObject((HGDIOBJ*)&hpenBtnText); // clean up objects we don't actually create AfxDeleteObject((HGDIOBJ*)&hStatusFont); AfxDeleteObject((HGDIOBJ*)&hToolTipsFont); }
void AFX_CDECL AfxTrackerTerm() { AfxDeleteObject((HGDIOBJ*)&_afxHatchBrush); AfxDeleteObject((HGDIOBJ*)&_afxBlackDottedPen); }
// Termination code AUX_DATA::~AUX_DATA() { // clean up objects we don't actually create AfxDeleteObject((HGDIOBJ*)&hbmMenuDot); }
void AFX_CDECL AfxWingdixTerm() { AfxDeleteObject((HGDIOBJ*)&_afxHalftoneBrush); }
void CFlatToolbar::EndDrawButton(DrawState& ds) { SelectObject(hDCMono, ds.hbmMonoOld); AfxDeleteObject((HGDIOBJ*)&ds.hbmMono); SelectObject(hDCGlyphs, ds.hbmOldGlyphs); }
CPreviewDC::~CPreviewDC() { ASSERT(m_hDC == NULL); // Should not have a screen DC at this time AfxDeleteObject((HGDIOBJ*)&m_hFont); }
CFlatToolbar::CFlatToolbar() { m_hbmImageWell = NULL; m_hInstImageWell = NULL; m_hRsrcImageWell = NULL; m_iButtonCapture = -1; // nothing captured // TONYCL: START: OFFICE97 LOOK AND FEEL m_nUpButtonIndex = -1; // No previous upstate button // TONYCL: END: OFFICE97 LOOK AND FEEL // UISG standard sizes m_sizeButton.cx = 24; m_sizeButton.cy = 22; m_sizeImage.cx = 16; m_sizeImage.cy = 15; // MATTGR smaller top and bottom gaps // 3 pixel for top/bottom gaps m_cyTopBorder = 2; m_cyBottomBorder = 2; // adjust sizes when running on Win4 if (globalData.bWin4) { m_sizeButton.cx = 23; m_cySharedBorder = m_cxSharedBorder = 0; m_cxDefaultGap = 8; } else { m_cxDefaultGap = 6; m_cySharedBorder = m_cxSharedBorder = 1; } #ifdef _MAC m_hDCGlyphs = CreateCompatibleDC(NULL); m_hDCMono = ::CreateCompatibleDC(NULL); if (m_hDCGlyphs == NULL || m_hDCMono == NULL) AfxThrowResourceException(); #endif // initialize the toolbar drawing engine static BOOL bInitialized; if (!bInitialized) { #ifndef _MAC hDCGlyphs = CreateCompatibleDC(NULL); // Mono DC and Bitmap for disabled image hDCMono = ::CreateCompatibleDC(NULL); #endif #ifndef _MAC HBITMAP hbmGray = ::CreateDitherBitmap(); #else HBITMAP hbmGray = ::CreateDitherBitmap(m_bMonochrome); #endif if (hbmGray != NULL) { ASSERT(hbrDither == NULL); hbrDither = ::CreatePatternBrush(hbmGray); AfxDeleteObject((HGDIOBJ*)&hbmGray); } #ifndef _MAC if (hDCGlyphs == NULL || hDCMono == NULL || hbrDither == NULL) AfxThrowResourceException(); #else if (hbrDither == NULL) AfxThrowResourceException(); #endif bInitialized = TRUE; } }
~_AFX_TRACKER_TERM() { AfxDeleteObject((HGDIOBJ*)&hatchBrush); AfxDeleteObject((HGDIOBJ*)&blackDottedPen); }
void CPreviewDC::MirrorFont() { if (m_hAttribDC == NULL) return; // Can't do anything without Attrib DC if (m_hPrinterFont == NULL) { SelectStockObject(DEVICE_DEFAULT_FONT); // will recurse return; } if (m_hDC == NULL) return; // can't mirror font without a screen DC LOGFONT logFont; // Fill the logFont structure with the original info ::GetObject(m_hPrinterFont, sizeof(LOGFONT), (LPVOID)&logFont); TEXTMETRIC tm; GetTextFace(LF_FACESIZE, (LPTSTR)&logFont.lfFaceName[0]); GetTextMetrics(&tm); // Set real values based on the Printer's text metrics. if (tm.tmHeight < 0) logFont.lfHeight = tm.tmHeight; else logFont.lfHeight = -(tm.tmHeight - tm.tmInternalLeading); logFont.lfWidth = 0; logFont.lfWeight = tm.tmWeight; logFont.lfItalic = tm.tmItalic; logFont.lfUnderline = tm.tmUnderlined; logFont.lfStrikeOut = tm.tmStruckOut; logFont.lfCharSet = tm.tmCharSet; logFont.lfPitchAndFamily = tm.tmPitchAndFamily; HFONT hNewFont = ::CreateFontIndirect(&logFont); ::SelectObject(m_hDC, hNewFont); ::GetTextMetrics(m_hDC, &tm); // Is the displayed font too large? int cyDesired = -logFont.lfHeight; int cyActual; if (tm.tmHeight < 0) cyActual = -tm.tmHeight; else cyActual = tm.tmHeight - tm.tmInternalLeading; CSize sizeWinExt; VERIFY(::GetWindowExtEx(m_hDC, &sizeWinExt)); CSize sizeVpExt; VERIFY(::GetViewportExtEx(m_hDC, &sizeVpExt)); // Only interested in Extent Magnitudes, not direction if (sizeWinExt.cy < 0) sizeWinExt.cy = -sizeWinExt.cy; if (sizeVpExt.cy < 0) sizeVpExt.cy = -sizeVpExt.cy; // Convert to screen device coordinates to eliminate rounding // errors as a source of SmallFont aliasing cyDesired = MulDiv(cyDesired, sizeVpExt.cy, sizeWinExt.cy); cyActual = MulDiv(cyActual, sizeVpExt.cy, sizeWinExt.cy); ASSERT(cyDesired >= 0 && cyActual >= 0); if (cyDesired < cyActual) { logFont.lfFaceName[0] = 0; // let the mapper find a good fit if ((logFont.lfPitchAndFamily & 0xf0) == FF_DECORATIVE) logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DECORATIVE; else logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; HFONT hTempFont = ::CreateFontIndirect(&logFont); ::SelectObject(m_hDC, hTempFont); // Select it in. ::DeleteObject(hNewFont); hNewFont = hTempFont; } AfxDeleteObject((HGDIOBJ*)&m_hFont); // delete the old logical font m_hFont = hNewFont; // save the new one #ifdef _MAC VERIFY(::GetCharWidth(m_hDC, 0, 255, m_aCharWidthsDraw)); VERIFY(::GetCharWidth(m_hAttribDC, 0, 255, m_aCharWidthsAttrib)); #endif }