Hi, I have an ActiveX digital clock and the following code is in the OnDraw()
function:

HRESULT OnDraw(ATL_DRAWINFO& di)
{
RECT& rc = *(RECT*)di.prcBounds;
HBRUSH hBrush, hOldBrush;
hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
hOldBrush = (HBRUSH)SelectObject(di.hdcDraw, hBrush);
Rectangle(
di.hdcDraw,
rc.left,
rc.top,
rc.right,
rc.bottom);
SelectObject(di.hdcDraw, hOldBrush);

TCHAR pszText[10];

wsprintf(pszText, _T("%02d:%02d:%02d"),
m_sHour, m_sMinute, m_sSecond);

DrawText(
di.hdcDraw,
pszText,
-1,
&rc,
DT_CENTER | DT_VCENTER | DT_SINGLELINE);

return S_OK;
}

How can I change the font and size so that I can change the appearance of
the clock?


Thanks for any help you guys can give me.

Re: Change Font help by Jjoony

Jjoony
Fri Sep 15 20:42:36 CDT 2006

Hi

For font, search for CreateFontIndirect() and LOGFONT structure.
It is GDI object, so you can use SelectObject() to use it.
It is WIN32 API, so if you are using MFC, there might be some similar
classes, too.

Cheers

"Wanting2Learn" <Wanting2Learn@discussions.microsoft.com> wrote in message
news:B4784A2A-4E12-4812-90E7-E9EE566BD3F5@microsoft.com...
> Hi, I have an ActiveX digital clock and the following code is in the
> OnDraw()
> function:
>
> HRESULT OnDraw(ATL_DRAWINFO& di)
> {
> RECT& rc = *(RECT*)di.prcBounds;
> HBRUSH hBrush, hOldBrush;
> hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
> hOldBrush = (HBRUSH)SelectObject(di.hdcDraw, hBrush);
> Rectangle(
> di.hdcDraw,
> rc.left,
> rc.top,
> rc.right,
> rc.bottom);
> SelectObject(di.hdcDraw, hOldBrush);
>
> TCHAR pszText[10];
>
> wsprintf(pszText, _T("%02d:%02d:%02d"),
> m_sHour, m_sMinute, m_sSecond);
>
> DrawText(
> di.hdcDraw,
> pszText,
> -1,
> &rc,
> DT_CENTER | DT_VCENTER | DT_SINGLELINE);
>
> return S_OK;
> }
>
> How can I change the font and size so that I can change the appearance of
> the clock?
>
>
> Thanks for any help you guys can give me.
>