对话框美化教程.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
对话框美化教程.doc

1.设置对话框背景图片?? 插入资源中--插入--Bitmap--引入 要设置成背景的图片 (本例引入两个ID分别为IDB_BITMAP1,IDB_BITMAP2) 拉入图像?? 设置成位图--然后选择 属性(M)中选择位图的ID ?? 2.设置对话框背景颜色?? 在.cpp中 BOOL CMyApp::InitInstance() { ???? AfxEnableControlContainer(); ???? // Standard initialization ???? // If you are not using these features and wish to reduce the size ???? //?? of your final executable, you should remove from the following ???? //?? the specific initialization routines you do not need. #ifdef _AFXDLL ???? Enable3dControls();???????????? // Call this when using MFC in a shared DLL #else ???? Enable3dControlsStatic();???? // Call this when linking to MFC statically #endif ???? CMyDlg dlg; ???? m_pMainWnd = dlg; ???? SetDialogBkColor(RGB(255,255,255),RGB(0,0,0));//这里设置对话框背景颜色为白色,文本 //颜色为黑色 ???? int nResponse = dlg.DoModal(); ???? if (nResponse == IDOK) ???? { ???????? // TODO: Place code here to handle when the dialog is ???????? //?? dismissed with OK ???? } ???? else if (nResponse == IDCANCEL) ???? { ???????? // TODO: Place code here to handle when the dialog is ???????? //?? dismissed with Cancel ???? } ???? // Since the dialog has been closed, return FALSE so that we exit the ???? //?? application, rather than start the applications message pump. ???? return FALSE; } 3.设置按钮位图???? 插入Bitmap (ID分别为IDB_BITMAP3,IDB_BITMAP4) 在对话框头文件中定义CBitmap; protected: ???? CBitmap bitmap1,bitmap2; 然后在对话框Dlg.cpp文件中的OnIniDialog()中加入以下代码 ???? bitmap1.LoadBitmap(IDB_BITMAP3); ???? CButton *m_pButton1, *m_pButton2; ???? m_pButton1=(CButton*)GetDlgItem(IDOK); ???? m_pButton1-SetBitmap(HBITMAP(bitmap1)); ???? bitmap2.LoadBitmap(IDB_BITMAP4); ???? m_pButton2=(CButton*)GetDlgItem(IDC_HAHA); ???? m_pButton2-SetBitmap(HBITMAP(bitmap2)); ???? // TODO: Add extra initialization here 然后编译运行?? 看下效果? [顶]在VC中让对话框显示背景图 [点评:用图片控件,好像图片最多色彩数不超过256色,也就是8位,但是用代码在里面写的方法就可以解决这个问题了.] 让一个对话框显示背景通常有两种做法:使用图片控件、在WM_PAINT消息中画图。 用图片控件非常简单,但功能功能不强大,不能对图片拉申等。 在WM_PAINT中画图,相对复杂,但可以做很多特殊处理(如对图片拉申、图片取反等等)。 那么下面就对两种方法略述。 1、用图片控件   在对话框中加入Pict

文档评论(0)

zhangxiuli01 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档