好象是设置这个icon?这个icon是什么?void CMyTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting 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);
}
else
{
CDialog::OnPaint();
}
}
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting 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);
}
else
{
CDialog::OnPaint();
}
}
解决方案 »
- 【问题】CImage或CBitmap如何接收二进制数据以便显示二进制所表示的图片?
- 关于CScrollView
- win32 程序开发
- Edit控件的问题
- 散分散分
- 关于WSAEventSelect,为什么FD_WRITE事件只响应一次啊,大家帮我看看。。。。
- 我的socket为什么close时候出错???大家进来看看啊-wl
- using namespace std;???什么意思?有什么用?
- 要让windows一开机便执行某个程式,我应该将其放在注册表的哪个位置?
- 请问wpe截获程序发送和接受的数据的原理是什么啊?
- 函数里怎么传递一个未知的类啊?在这函数里可使用new来创建这个类的实例?
- 谁有思科2950交换机的MIB文件?
{
if (IsIconic())//如果对话框最小化了
{
CPaintDC dc(this); // 取得对话框的PaintDC
//向该对话框发送WM_ICONERASEBKGND消息,该消息的详细含义可以通过
//MSDN获得
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;//计算ICON左上角的X坐标
int y = (rect.Height() - cyIcon + 1) / 2;//计算ICON左上角的Y坐标 // Draw the icon
dc.DrawIcon(x, y, m_hIcon);//绘制图标
}
else//在对话框非最小化的时候调用
{
CDialog::OnPaint();
}
}
希望对你有所帮助!
CRect rect;
GetClientRect(&rect); //获取客户区域吧 最小化了客户区是哪个??;
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; //这两句什么用?x y是那里坐标?