Example #1
0
void CMainWindow::OnPaint ()
{
	CRect rect;
	GetClientRect(&rect);


    CPaintDC dc (this);
	dc.SetViewportOrg(rect.Width()/2, rect.Height()/2);
	dc.SetBkMode(TRANSPARENT);

	for (int i = 0; i<300; i+=150)
	{
		LOGFONT lf;
		::ZeroMemory(&lf, sizeof(LOGFONT));
		lf.lfHeight = 160;
		lf.lfHeight = FW_BOLD;
		lf.lfEscapement = i;
		lf.lfOrientation = i;
		::lstrcpy(lf.lfFaceName, _T("Arial"));

		CFont font;
		font.CreateFontIndirect(&lf);

		CFont * pOldFont = dc.SelectObject(&font);
		dc.TextOut(0,0, CString(_T("M")));
		dc.SelectObject(pOldFont);
	}

}
Example #2
0
void CMainWindow::OnPaint ()
{
    CPaintDC dc (this);
    
    //
    // Initialize the device context.
    //
    dc.SetMapMode (MM_LOENGLISH);
    dc.SetTextAlign (TA_CENTER | TA_BOTTOM);
    dc.SetBkMode (TRANSPARENT);

    //
    // Draw the body of the ruler.
    //
    CBrush brush (RGB (255, 255, 0));
    CBrush* pOldBrush = dc.SelectObject (&brush);
    dc.Rectangle (100, -100, 1300, -200);
    dc.SelectObject (pOldBrush);

    //
    // Draw the tick marks and labels.
    //
    for (int i=125; i<1300; i+=25) {
        dc.MoveTo (i, -192);
        dc.LineTo (i, -200);
    }

    for (i=150; i<1300; i+=50) {
        dc.MoveTo (i, -184);
        dc.LineTo (i, -200);
    }

    for (i=200; i<1300; i+=100) {
        dc.MoveTo (i, -175);
        dc.LineTo (i, -200);

        CString string;
        string.Format (_T ("%d"), (i / 100) - 1);
        dc.TextOut (i, -175, string);
    }
}