void CSplashScreen::OnPaint() { CPaintDC dc(this); // device context for painting if (m_imgSplash.GetSafeHandle()) { CDC dcMem; if (dcMem.CreateCompatibleDC(&dc)) { CBitmap* pOldBM = dcMem.SelectObject(&m_imgSplash); BITMAP BM; m_imgSplash.GetBitmap(&BM); dc.BitBlt(0, 0, BM.bmWidth, BM.bmHeight, &dcMem, 0, 0, SRCCOPY); if (pOldBM) dcMem.SelectObject(pOldBM); CRect rc(0, (int)(BM.bmHeight * 0.65), BM.bmWidth, BM.bmHeight); dc.FillSolidRect(rc.left+1, rc.top+1, rc.Width()-2, rc.Height()-2, RGB(255,255,255)); LOGFONT lf = {0}; lf.lfHeight = 30; lf.lfWeight = FW_BOLD; lf.lfQuality = afxIsWin95() ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY; _tcscpy(lf.lfFaceName, _T("Arial")); CFont font; font.CreateFontIndirect(&lf); CFont* pOldFont = dc.SelectObject(&font); CString strAppVersion(_T("eMule ") + theApp.m_strCurVersionLong); rc.top += dc.DrawText(strAppVersion, &rc, DT_CENTER | DT_NOPREFIX); if (pOldFont) dc.SelectObject(pOldFont); font.DeleteObject(); rc.top += 8; lf.lfHeight = 14; lf.lfWeight = FW_NORMAL; lf.lfQuality = afxIsWin95() ? NONANTIALIASED_QUALITY : ANTIALIASED_QUALITY; _tcscpy(lf.lfFaceName, _T("Arial")); font.CreateFontIndirect(&lf); pOldFont = dc.SelectObject(&font); dc.DrawText(_T("Copyright (C) 2002-2015 Merkur"), &rc, DT_CENTER | DT_NOPREFIX); if (pOldFont) dc.SelectObject(pOldFont); font.DeleteObject(); } } }
void CHTRichEditCtrl::ScrollToFirstLine() { // WM_VSCROLL does not work correctly under Win98 (or older version of comctl.dll) SendMessage(WM_VSCROLL, SB_TOP); if (afxIsWin95()) { // older version of comctl.dll seem to need this to properly update the display int iPos = GetScrollPos(SB_VERT); SendMessage(WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, iPos)); SendMessage(WM_VSCROLL, SB_ENDSCROLL); } }
TEMPLATE void CDialogMinTrayBtn<BASE>::MinTrayBtnInit() { m_nMinTrayBtnTimerId = 0; BOOL bBmpResult = MinTrayBtnInitBitmap(); // - Never use the 'TransparentBlt' function under Win9x (read SDK) // - Load the 'MSIMG32.DLL' only, if it's really needed. if (!afxIsWin95() && bBmpResult && !s_pfnTransparentBlt) { HMODULE hMsImg32 = LoadLibrary(_T("MSIMG32.DLL")); if (hMsImg32) { (FARPROC &)s_pfnTransparentBlt = GetProcAddress(hMsImg32, "TransparentBlt"); if (!s_pfnTransparentBlt) FreeLibrary(hMsImg32); } } }
void CHTRichEditCtrl::ScrollToLastLine(bool bForceLastLineAtBottom) { if (bForceLastLineAtBottom) { int iFirstVisible = GetFirstVisibleLine(); if (iFirstVisible > 0) LineScroll(-iFirstVisible); } // WM_VSCROLL does not work correctly under Win98 (or older version of comctl.dll) SendMessage(WM_VSCROLL, SB_BOTTOM); if (afxIsWin95()) { // older version of comctl.dll seem to need this to properly update the display int iPos = GetScrollPos(SB_VERT); SendMessage(WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, iPos)); SendMessage(WM_VSCROLL, SB_ENDSCROLL); } }
void CHTRichEditCtrl::Init(LPCTSTR pszTitle, LPCTSTR pszSkinKey) { SetProfileSkinKey(pszSkinKey); SetTitle(pszTitle); VERIFY( SendMessage(EM_SETUNDOLIMIT, 0, 0) == 0 ); int iMaxLogBuff = thePrefs.GetMaxLogBuff(); if (afxIsWin95()) LimitText(iMaxLogBuff > 0xFFFF ? 0xFFFF : iMaxLogBuff); else LimitText(iMaxLogBuff ? iMaxLogBuff : 128*1024); m_iLimitText = GetLimitText(); VERIFY( GetSelectionCharFormat(m_cfDefault) ); // prevent the RE control to change the font height within single log lines (may happen with some Unicode chars) DWORD dwLangOpts = SendMessage(EM_GETLANGOPTIONS); SendMessage(EM_SETLANGOPTIONS, 0, dwLangOpts & ~(IMF_AUTOFONT /*| IMF_AUTOFONTSIZEADJUST*/)); //SendMessage(EM_SETEDITSTYLE, SES_EMULATESYSEDIT, SES_EMULATESYSEDIT); }
void COScopeCtrl::InvalidateCtrl(bool deleteGraph) { int i, j, GridPos; int nCharacters; CPen *oldPen; CPen solidPen(PS_SOLID, 0, m_crGridColor); CFont yUnitFont, *oldFont; CString strTemp; CClientDC dc(this); // if we don't have one yet, set up a memory dc for the grid if (m_dcGrid.GetSafeHdc() == NULL) { m_dcGrid.CreateCompatibleDC(&dc); m_bitmapGrid.DeleteObject(); m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight); m_bitmapOldGrid.Attach(SelectObject(m_dcGrid, m_bitmapGrid)); } COLORREF crLabelBk; COLORREF crLabelFg; bool bStraightGraphs = true; if (bStraightGraphs) { // Get the background color from the parent window. This way the controls which are // embedded in a dialog window can get painted with the same background color as // the dialog window. HBRUSH hbr = (HBRUSH)GetParent()->SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dc.m_hDC, (LPARAM)m_hWnd); if (hbr == GetSysColorBrush(COLOR_WINDOW)) crLabelBk = GetSysColor(COLOR_WINDOW); else crLabelBk = GetSysColor(COLOR_BTNFACE); crLabelFg = GetSysColor(COLOR_WINDOWTEXT); } else { crLabelBk = m_crBackColor; crLabelFg = m_crGridColor; } // fill the grid background m_dcGrid.FillSolidRect(m_rectClient, crLabelBk); // draw the plot rectangle: determine how wide the y axis scaling values are double fAbsUpperLimit = fabs(m_PlotData[0].dUpperLimit); if (fAbsUpperLimit > 0.0) nCharacters = abs((int)log10(fAbsUpperLimit)); else nCharacters = 0; double fAbsLowerLimit = fabs(m_PlotData[0].dLowerLimit); if (fAbsLowerLimit > 0.0) nCharacters = max(nCharacters, abs((int)log10(fAbsLowerLimit))); // add the units digit, decimal point and a minus sign, and an extra space // as well as the number of decimal places to display nCharacters = nCharacters + 4 + m_nYDecimals; // adjust the plot rectangle dimensions // Changed this so that the Y-Units wouldn't overlap the Y-Scale. m_rectPlot.left = m_rectClient.left + 8*7+4;//(nCharacters) ; m_nPlotWidth = m_rectPlot.Width(); // draw the plot rectangle if (bStraightGraphs) { m_dcGrid.FillSolidRect(m_rectPlot.left, m_rectPlot.top, m_rectPlot.right - m_rectPlot.left + 1, m_rectPlot.bottom - m_rectPlot.top + 1, m_crBackColor); CRect rcPlot(m_rectPlot); rcPlot.left -= 1; rcPlot.top -= 1; rcPlot.right += 3; rcPlot.bottom += 3; m_dcGrid.DrawEdge(rcPlot, EDGE_SUNKEN, BF_RECT); } else { oldPen = m_dcGrid.SelectObject(&solidPen); m_dcGrid.MoveTo(m_rectPlot.left, m_rectPlot.top); m_dcGrid.LineTo(m_rectPlot.right + 1, m_rectPlot.top); m_dcGrid.LineTo(m_rectPlot.right + 1, m_rectPlot.bottom + 1); m_dcGrid.LineTo(m_rectPlot.left, m_rectPlot.bottom + 1); m_dcGrid.LineTo(m_rectPlot.left, m_rectPlot.top); m_dcGrid.SelectObject(oldPen); } // draw the dotted lines, // use SetPixel instead of a dotted pen - this allows for a finer dotted line and a more "technical" look for (j = 1; j < m_nYGrids + 1; j++) { GridPos = m_rectPlot.Height() * j / (m_nYGrids + 1) + m_rectPlot.top; for (i = m_rectPlot.left; i < m_rectPlot.right; i += 4) m_dcGrid.SetPixel(i, GridPos, m_crGridColor); } if (thePrefs.m_bShowVerticalHourMarkers) { // Add vertical reference lines in the graphs. Each line indicates an elapsed hour from the current // time (extreme right of the graph). // Lines are always right aligned and the gap scales accordingly to the user horizontal scale. // Intervals of 10 hours are marked with slightly stronger lines that go beyond the bottom border. int hourSize, partialSize, surplus=0, extra=0; if (m_nXGrids > 0) { hourSize = (3600*m_rectPlot.Width())/(3600*m_nXGrids + m_nXPartial); // Size of an hour in pixels partialSize = m_rectPlot.Width() - hourSize*m_nXGrids; if (partialSize >= hourSize) { partialSize = (hourSize*m_nXPartial)/3600; // real partial size surplus = m_rectPlot.Width() - hourSize*m_nXGrids - partialSize; // Pixel surplus } GridPos = 0; for(j = 1; j <= m_nXGrids; j++) { extra = 0; if (surplus) { surplus--; extra=1; } GridPos += (hourSize+extra); if ((m_nXGrids - j + 1) % 10 == 0) { for(i = m_rectPlot.top; i < m_rectPlot.bottom; i += 2) m_dcGrid.SetPixel(m_rectPlot.left + GridPos - hourSize + partialSize, i, m_crGridColor); } else { for(i = m_rectPlot.top; i < m_rectPlot.bottom; i += 4) m_dcGrid.SetPixel(m_rectPlot.left + GridPos - hourSize + partialSize, i, m_crGridColor); } } } } if (afxIsWin95()) { // Win98: To get a rotated font it has to be specified as "Arial" ("MS Shell Dlg" // and "MS Sans Serif" are not created with rotation) yUnitFont.CreateFont(FontPointSizeToLogUnits(8*10), 0, 900, 900, FW_NORMAL, FALSE, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Arial")); } else { yUnitFont.CreateFont(FontPointSizeToLogUnits(8*10), 0, 900, 900, FW_NORMAL, FALSE, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, theApp.GetDefaultFontFaceName()); } // grab the horizontal font oldFont = m_dcGrid.SelectObject(&sm_fontAxis); // y max m_dcGrid.SetTextColor(crLabelFg); m_dcGrid.SetBkColor(crLabelBk); m_dcGrid.SetTextAlign(TA_RIGHT | TA_TOP); if (m_str.YMax.IsEmpty()) strTemp.Format(_T("%.*lf"), m_nYDecimals, m_PlotData[0].dUpperLimit); else strTemp = m_str.YMax; m_dcGrid.TextOut(m_rectPlot.left - 4, m_rectPlot.top - 7, strTemp); if (m_rectPlot.Height() / (m_nYGrids + 1) >= 14) { for (j = 1; j < (m_nYGrids + 1); j++) { GridPos = m_rectPlot.Height() * j / (m_nYGrids + 1) + m_rectPlot.top; strTemp.Format(_T("%.*lf"), m_nYDecimals, m_PlotData[0].dUpperLimit * (m_nYGrids - j + 1) / (m_nYGrids + 1)); m_dcGrid.TextOut(m_rectPlot.left - 4, GridPos - 7, strTemp); } } else { strTemp.Format(_T("%.*lf"), m_nYDecimals, m_PlotData[0].dUpperLimit / 2); m_dcGrid.TextOut(m_rectPlot.left - 2, m_rectPlot.bottom + ((m_rectPlot.top - m_rectPlot.bottom) / 2) - 7 , strTemp); } // y min if (m_str.YMin.IsEmpty()) strTemp.Format(_T("%.*lf"), m_nYDecimals, m_PlotData[0].dLowerLimit); else strTemp = m_str.YMin; m_dcGrid.TextOut(m_rectPlot.left - 4, m_rectPlot.bottom - 7, strTemp); // x units m_dcGrid.SetTextAlign(TA_RIGHT | TA_BOTTOM); m_dcGrid.TextOut(m_rectClient.right - 2, m_rectClient.bottom - 2, m_str.XUnits); // restore the font m_dcGrid.SelectObject(oldFont); // y units oldFont = m_dcGrid.SelectObject(&yUnitFont); m_dcGrid.SetTextAlign(TA_CENTER | TA_BASELINE); CRect rText(0,0,0,0); m_dcGrid.DrawText(m_str.YUnits, rText, DT_CALCRECT); m_dcGrid.TextOut((m_rectClient.left + m_rectPlot.left - 8) / 2 - rText.Height() / 2, (m_rectPlot.bottom + m_rectPlot.top) / 2 - rText.Height() / 2, m_str.YUnits ); m_dcGrid.SelectObject(oldFont); oldFont = m_dcGrid.SelectObject(&sm_fontAxis); m_dcGrid.SetTextAlign(TA_LEFT | TA_TOP); int xpos = m_rectPlot.left + 2; int ypos = m_rectPlot.bottom + 3; for (i = 0; i < m_NTrends; i++) { CSize sizeLabel = m_dcGrid.GetTextExtent(m_PlotData[i].LegendLabel); if (xpos + 12 + sizeLabel.cx + 12 > m_rectPlot.right) { xpos = m_rectPlot.left + 2; ypos = m_rectPlot.bottom + sizeLabel.cy + 2; } if (bStraightGraphs) { const int iLegFrmD = 1; CPen penFrame(PS_SOLID, iLegFrmD, crLabelFg); oldPen = m_dcGrid.SelectObject(&penFrame); const int iLegBoxW = 9; const int iLegBoxH = 9; CRect rcLegendFrame; rcLegendFrame.left = xpos - iLegFrmD; rcLegendFrame.top = ypos + 2 - iLegFrmD; rcLegendFrame.right = rcLegendFrame.left + iLegBoxW + iLegFrmD; rcLegendFrame.bottom = rcLegendFrame.top + iLegBoxH + iLegFrmD; m_dcGrid.MoveTo(rcLegendFrame.left, rcLegendFrame.top); m_dcGrid.LineTo(rcLegendFrame.right, rcLegendFrame.top); m_dcGrid.LineTo(rcLegendFrame.right, rcLegendFrame.bottom); m_dcGrid.LineTo(rcLegendFrame.left, rcLegendFrame.bottom); m_dcGrid.LineTo(rcLegendFrame.left, rcLegendFrame.top); m_dcGrid.SelectObject(oldPen); m_dcGrid.FillSolidRect(xpos, ypos + 2, iLegBoxW, iLegBoxH, m_PlotData[i].crPlotColor); m_dcGrid.SetBkColor(crLabelBk); } else { CPen LegendPen(PS_SOLID, 3, m_PlotData[i].crPlotColor); oldPen = m_dcGrid.SelectObject(&LegendPen); m_dcGrid.MoveTo(xpos, ypos + 8); m_dcGrid.LineTo(xpos + 8, ypos + 4); m_dcGrid.SelectObject(oldPen); } m_dcGrid.TextOut(xpos + 12, ypos, m_PlotData[i].LegendLabel); xpos += 12 + sizeLabel.cx + 12; } m_dcGrid.SelectObject(oldFont); // if we don't have one yet, set up a memory dc for the plot if (m_dcPlot.GetSafeHdc() == NULL) { m_dcPlot.CreateCompatibleDC(&dc); m_bitmapPlot.DeleteObject(); m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight); m_bitmapOldPlot.Attach(SelectObject(m_dcPlot, m_bitmapPlot)); } // make sure the plot bitmap is cleared if (deleteGraph) m_dcPlot.FillSolidRect(m_rectClient, m_crBackColor); int iNewSize = m_rectClient.Width() / m_nShiftPixels + 10; // +10 just in case :) if (m_nMaxPointCnt < iNewSize) m_nMaxPointCnt = iNewSize; if (theApp.emuledlg->IsRunning()) { if (!thePrefs.IsGraphRecreateDisabled()) { // The timer will redraw the previous points in 200ms m_bDoUpdate = false; if (m_nRedrawTimer) KillTimer(m_nRedrawTimer); VERIFY( (m_nRedrawTimer = SetTimer(1612, 200, NULL)) != NULL ); // reduce flickering } } InvalidateRect(m_rectClient); }