MFC背景颜色

本文介绍了如何在MFC中通过CWinApp::SetDialogBkColor改变对话框背景颜色,CWnd::OnPaint进行窗口背景填充,并利用CWnd::OnCtlColor定制控件和对话框的颜色。详细讲述了各个方法的使用和实现过程。
摘要由CSDN通过智能技术生成

1、从InitInstance设置应用程序默认背景和对话框颜色。

CWinApp::SetDialogBkColor

This method is called from within the InitInstance method to set the default background and text color for dialog boxes and message boxes within your application.

void SetDialogBkColor( 
COLORREF clrCtlBk = RGB(192, 192, 192), 
COLORREF clrCtlText = RGB(0, 0, 0) ); 
eg:

        CMyDlg dlg;
SetDialogBkColor(RGB(69,137,148),RGB(220,20,10));
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();


2、使用OPaint设置应用程序默认背景。

CWnd::OnPaint 

afx_msg void OnPaint( );

Remarks

The framework calls this member function when Windows or an application makes a request to repaint a portion of an application’s window. TheWM_PAINT message is sent when the UpdateWindow or RedrawWindow member function is called.

A window may receive internal paint messages as a result of calling the RedrawWindow member function with the RDW_INTERNALPAINT flag set. In this case, the window may not have an update region. An application should call the GetUpdateRect member function to

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值