CDialog划分为两个背景不同的区域(内部目标的图片)
问题说明
我需要构建一个设计成完全像这样的窗口(它在白色区域内具有控件,但这暂时不相关):
I need to build a window designed to look exactly like this (it has controls inside the white area, but that's not relevant for now):
http://dl.dropbox.com/u/3432167/example.png
我的问题是用不同的背景定义这两个单独的区域".
我最接近预期外观的是用空的ListBox表示白色区域,但是结果不一样(这是一个糟糕的hack).
http://dl.dropbox.com/u/3432167/example.png
My problem is defining those two separate "areas" with different backgrounds.
The closest I've got to the expected look was representing the white area with an empty ListBox, but the result is not the same (and it is a lousy hack).
关于如何实现这一目标的任何想法?
Any ideas on how achieve this?
正确答案
经过一番挖掘,我发现一种很好的方法是重写OnPaint函数.
以下是用于上述问题的对话框的示例.矩形尺寸是硬编码的,因为此特定对话框不可调整大小.
After some digging, I've discovered that a good way to do this is overriding the OnPaint function.
Below is an example used for the dialog pictured on the question above. The rectangle dimensions are hard-coded because this particular dialog is not resizeable.
不要忘记将ON_WM_PAINT()添加到消息映射中.
Don't forget to add ON_WM_PAINT() to the message map.
void CTestDlg::OnPaint()
{
if (IsIconic())
{
(...)
}
else
{
CPaintDC dc(this); // device context for painting
dc.FillSolidRect(0,0,612,376, RGB(255,255,255));
dc.FillSolidRect(0,376,612,60, ::GetSysColor(COLOR_3DFACE));
CDialog::OnPaint();
}
}
该解决方案最终变得非常简单,但无论如何我认为共享还是很有用的.
The solution ended up being quite simple, but I guess useful to share anyway.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhchabbc
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20