Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Thursday, March 17, 2005

WM_CTLCOLORSTATIC change text color

ON_MESSAGE(WM_CTLCOLORSTATIC,OnCtrlColorStatic)

LRESULT CxxxDlg::OnCtrlColorStatic( WPARAM w, LPARAM p)
{
LRESULT lr = DefWindowProc(WM_CTLCOLORSTATIC,w,p);
HDC hdc = reinterpret_cast(w);
HWND hstatic = reinterpret_cast(p);
if(::GetDlgCtrlID(hstatic)==IDS_SERVER_NAME)
{
SetTextColor(hdc,RGB(255,0,0));
SetBkMode(hdc,TRANSPARENT);
}
return lr;
}

WM_SETFONT and WM_GETFONT change font of stat ic control in OnInitDialog

HFONT hfOld = (HFONT)::SendDlgItemMessage (this->m_hWnd,
IDS_SERVER_NAME, WM_GETFONT, 0, 0);
LOGFONT lf;
GetObject (hfOld, sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
HDC desktopdc = ::GetDC(::GetDesktopWindow());
lf.lfHeight = -MulDiv(7, GetDeviceCaps(desktopdc, LOGPIXELSY), 72);
DeleteDC(desktopdc);
::SendDlgItemMessage (this->m_hWnd, IDS_SERVER_NAME, WM_SETFONT,
(WPARAM)CreateFontIndirect (&lf), 0);

Tuesday, March 15, 2005

ASSERT failed in DestroyWindow called by FilterToolTipMessage

I don't know how to correctly fix it. But here is a work around find by masterz.
#ifdef _DEBUG
AFX_MANAGE_STATE(AfxGetStaticModuleState( ))//20050316
_AFX_THREAD_STATE *pThreadState= AfxGetThreadState();
if ( pThreadState) {
pThreadState->m_pToolTip= NULL;
}
#endif