改变按钮背景颜色怎么不好使
#include<afxwin.h>#include <afxtempl.h>class CMainWindow : public CFrameWnd{public: DECLARE_MESSAGE_MAP()public: CMainWindow(); CString strClassName; HBRUSH h; CButton button;protected: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); void click();public: afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);};#include "CMainWindow.h"#include<locale.h>#include<TCHAR.H>/*#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")*/#include "resource.h"BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd) ON_BN_CLICKED(100,click) ON_WM_CTLCOLOR()END_MESSAGE_MAP()BOOL CMainWindow::PreCreateWindow(CREATESTRUCT& cs){ CFrameWnd::PreCreateWindow(cs); cs.dwExStyle = cs.dwExStyle & (!WS_EX_CLIENTEDGE); return TRUE;}CMainWindow::CMainWindow(){ strClassName = AfxRegisterWndClass (CS_HREDRAW | CS_VREDRAW, (AfxGetApp()) ->LoadStandardCursor(IDC_ARROW) , (HBRUSH)(COLOR_3DFACE+1), AfxGetApp() ->LoadStandardIcon(IDI_WINLOGO) ); Create(strClassName,L"",WS_OVERLAPPEDWINDOW | WS_VSCROLL); CRect r; r.left = 10; r.top = 220; r.right = 110; r.bottom = 320; button.Create(L"CButton",BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD /*| BS_ICON*/, r,this,100);// button.SetIcon( AfxGetApp()->LoadIconW(IDI_ICON1)); h = ::CreateSolidBrush( RGB(0,255,0) );}void CMainWindow::click(){ ::setlocale(LC_ALL,"chs");}HBRUSH CMainWindow::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor){ if( pWnd->m_hWnd == button.m_hWnd ) { return h; } return CFrameWnd::OnCtlColor(pDC, pWnd, nCtlColor);}