// 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.