关于OnPaint()和OnQueryDragIcon()两个函数
希望高手能够解释一下。// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CAPIHook_EXEDlg::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();
}
}// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CAPIHook_EXEDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;//这里调用什么意思
}
希望高手能够解释一下。// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CAPIHook_EXEDlg::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();
}
}// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CAPIHook_EXEDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;//这里调用什么意思
}
解决方案 »
- 我在写MFC共享dll模拟鼠标遇到的问题,求助
- Edit中如何响应回车键功能阿!!!
- 提一个关于void *变量的有趣问题,乞望指教!
- 怎样把gerber文件在VC上画出来??急!!大哥
- 关于收发邮件的问题(SMTP和POP3)
- 程序中用到了"winxp风格的按钮",中例子代码,在没有安装vc的环境下.就显示不出来了,哪位知道这样的代码用到了什么dll或者ocx文件??!!!
- Unsigned short int数据类型?
- 请问如何将一ID对应的各种资源都Disable?
- 请教mfc按钮问题,谢谢!
- Office功能掉用后,怎样才能把它关闭掉?
- 如何获取主板的唯一ID(序列号)?
- OnCtlColor中的一个问题!!!
OnPaint()是重绘,大小...。
CWnd::OnQueryDragIcon ()其实是一个回调函数,就是当鼠标拖动到CWnd的窗口上的时候,系统自动调用这个函数来确定显示什么样的拖动图标。
OnQueryDragIcon:The framework calls this member function by a minimized (iconic) window that does not have an icon defined for its class. The system makes this call to obtain the cursor to display while the user drags the minimized window.但是还不怎么理解这2个消息什么意思啊。OnPaint()为WM_PAIN消息,那OnQueryDragIcon ()是什么消息2.1.发送擦除背景的图片的消息,要进行背景图片的更换;
2.得到图片的宽高; //得到那个图片啊,这里也没指定那个图片啊
3.图片将要显示的位置;
4.在指定的位置显示图片;
5.显示鼠标的图标 //我在一些自己建的工程中也没这个消息啊,可是也可以找到鼠标啊能不能讲的具体点啊 谢谢了
ON_WM_ERASEBKGND当背景擦除时被调用,你如果不需要定制背景,DefWindowProc自然会用窗口类的刷子绘制背景,你也不必操心;
ON_WM_QUERYDRAGICON只有窗口在最小化时被拖动、而且窗口类没有注册缺省图标时才有用,而事实上,MFC的窗口类总是会注册图标的(DefWindowProc会返回这个图标),即使没有,Windows也会使用系统缺省图标,因此没有它也无关紧要