ok, several things...
1) don't do this stuff in PreCreateWindow...pre-create window is called before the about dialog has actually been created -- add a windows message handler for WM_INITDIALOG, if CAboutDlg is a CDialog derived class; otherwise add a WM_CREATE handler
2) under no circumstances should you ever pass an uninitialized pointer to a function (here, I'm referring to the local variable pWnd in CAboutDlg::PreCreateWindow)...because CAboutDlg is derived from CWnd, if I'm not mistaken, you can pass "this" to the button's Create function. You should do that anyway, since I assume you want the dialog to be the button's parent.
3) Don't declare the button as a local variable. It should be a member of the CAboutDlg class. If you declare it local, then its destructor will be called as soon as PreCreateWindow ends, and when the destructor is called for a window class, the attached window is destroyed, which means that even if you created the button successfully it would be destroyed before you could ever see it.
4) your declaration of the CMyBtn class should read as follows:
Code:
class CMyBtn : public CButton
The missing "public" is actually what's causing the error message you're asking about, but I'm pointing out some things that will give you errors after that one is resolved, as well.
5) You need to modify your CMyBtn::DrawItem code:
Code:
void CMyBtn::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
COLORREF clrBlue = RGB( 0, 0, 255 );
COLORREF clrOld;
CBrush brBlue( clrBlue );
CBrush* pbrOld;
pbrOld = dc.SelectObject(&brBlue );
// dc.Rectangle( 85, 85, 115, 115 );
RECT rect;
GetClientRect(&rect);
dc.Rectangle(0, 0, rect.right, rect.bottom);
clrOld = dc.SetBkColor(clrBlue);
dc.DrawText(_T("Hello"), &rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
dc.SetBkColor(clrOld);
dc.SelectObject(pbrOld);
dc.Detach();
}
With an owner-drawn button, you have to do ALL the drawing yourself, including the button's label, the "depressed" state, the focused state, etc. About the only thing Windows does for you is draw a gray background.