如何给C++程序创建的窗口改背景色
2个回答
展开全部
先创建一个单文档窗体工程,然后在其视类中,通过AppWizard为该类添加WM_CREATE消息的响应函数,最后在这个响应函数(OnCreate函数)中,调用SetClassLong函数修改窗口的背景。代码如下:
int CStyleView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetClassLong(m_hWnd, GCL_HBRBACKGROUND, (LONG)GetStockObject(BLACK_BRUSH)); // 通过第三个参数将窗口颜色修改为黑色的
return 0;
}
int CStyleView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetClassLong(m_hWnd, GCL_HBRBACKGROUND, (LONG)GetStockObject(BLACK_BRUSH)); // 通过第三个参数将窗口颜色修改为黑色的
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询