OnPaint问题
if (IsIconic())//判断给定窗口是否是最小化(图标化)的窗口
{
CPaintDC dc(this); // 构造一个CPaintDC对象,准备用于绘画的应用程序窗口
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);//重绘窗口
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);//得到系统缺省的图标的高度和宽度,
int cyIcon = GetSystemMetrics(SM_CYICON);//什么是系统缺省的图标高度和宽度?
CRect rect;
GetClientRect(&rect);//获取窗口客户区的坐标。客户区坐标指定客户区的左上角和右下角。
int x = (rect.Width() - cxIcon + 1) / 2;//???
int y = (rect.Height() - cyIcon + 1) / 2;//???
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);//???
如上这段代码,有几个地方不太懂,上述在注释中打问号的地方,希望大家帮我解答一下。重点说一下第五行,还有加问号的地方。谢谢啦
[解决办法]
呵呵,查下MSDN就可以了。
The WM_ICONERASEBKGND message is sent to a minimized window when the background of the icon must be filled before painting the icon. A window receives this message only if a class icon is defined for the window; otherwise, WM_ERASEBKGND is sent. This message is not sent by newer versions of Windows.
Remarks
Windows NT 3.51 and earlier: The DefWindowProc function fills the icon background with the class background brush of the parent window. On newer versions of Windows, the DefWindowProc function ignores the message.
[解决办法]
窗口重绘必然是由WM_PAINT消息引发的。
推荐看下《Windows程序设计》
[解决办法]
rect:
-------------------------
[解决办法]
[解决办法]
[解决办法]
-----------------
[解决办法]
[解决办法]
[解决办法]
m_hIcon
[解决办法]
[解决办法]
[解决办法]
-----------------
------解决方案--------------------
[解决办法]
[解决办法]
-------------------------
大概是这个意思。