OWNERDRAW的BUTTON怎么鼠标在上面晃就是收不到WM-MOUSEMOVE消息啊?一出去就收到了?? 你的rect是基于screen的还是client的。转换一下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我知道啊,lParam是客户区的,我也用ClientToScreen(hwnd,&point)换过了,并且调试的时候,我一出BUTTON区域,在立刻发生的WM-MOUSEMOVE中断处,查到point刚好是BUTTON的边界!这到底是怎么回事啊?? 我怀疑你的响应的不是BUTTON的MOUSEMOVE,而是它父窗口的MOUSEMOVE. 是不是这个消息被Button自己capture了? to shesh(无所谓),对对,我响应的是父窗口的MOUSEMOVE,我可以响应BUTTON的MOUSEMOVE吗?愿闻其详!解决后必以全分奉上! 那你要重载CButton了,不用MFC的话,偶不懂。 过程是这样的:point.x = LOWORD(lParam);point.y = HIWORD(lParam);rect = GetWindowRect(hButtuon,&rect);ClientToScreen(hwnd,&point);有问题吗?可就是不行啊! 在CButton类的派生类中重载PreTranslateMessage(),在里面捕获之,也可以自己仿照APPWIZARD建立的代码建立消息映射,通过消息映射处理这个消息 对话框捕获了mousemove消息 or Mr_Bomber is right 重载CButton类,响应WM_MOUSEMOVE消息和WM_MOUSELEAVE(未公开消息,在鼠标离开窗口时响应)。 SDK的话,用SetWindowLong给Button设置自己的消息处里函数吧,WM_MOUSEMOVE不是Notify类型的消息,不会发给父窗口的,不能直接定义消息映射 http://www.csdn.net/expert/topic/411/411075.shtm代码有13000行的超cool表格程序,如何开发成activeX控件,有兴趣的人留下email,我把源程序发给你们分数为150分十万火级,如能给出答案,再送300分有兴趣的人留下email我把程序发给你们。 一个很cool的表格程序,请问如何改为activeX控件,有兴趣的我把源代码发给你们,感兴趣的人留下email,是vc写的非常cool 鼠标移动到button上时,button 就将鼠标这是的移动消息截获了,换句话说,button 也是一个窗口,此时鼠标消息被这个窗口处理。而此时button这个wnd没有重载OnMouseMove函数的话,就处理不了MouseMove事件了。鼠标移动到button边界后从button窗口进入到了父窗口,这时父窗口处理MouseMove事件,所以会调用OnMouseMove函数。其实你只要只在button里重载OnMouseMove函数就能实现的,你可以试一下 to kingtsui,我在写SetWindowLong设置的消息处理函数时遇到问题了,程序怎么就不调用我的处理函数?我是在创建窗口的同时,调用SetWindowLong的,然后在消息处理函数的WM_DRAWITEM的消息里画BUTTON,可是画不出。 to Martens,我是用SDK的,你能从SDK的角度给我解释吗?谢谢了! 欧不懂咧,呵呵,非用SDK不可吗? 在MFC中用BUTTON的父类(对话框)SUBCLASSDLGITEM。实际上就是SDK中调用SETWINDOWLONG,见MFC\SRC\WINCORE.CPP中的函数实现。 建议重载CButton#if !defined(AFX_MYBUTTON_H__7C6D5CAA_A730_4F48_835F_956D31ECA192__INCLUDED_)#define AFX_MYBUTTON_H__7C6D5CAA_A730_4F48_835F_956D31ECA192__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000// MyButton.h : header file///////////////////////////////////////////////////////////////////////////////// CMyButton windowclass CMyButton : public CButton{// Constructionpublic: CMyButton();// Attributespublic:// Operationspublic:// Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMyButton) //}}AFX_VIRTUAL// Implementationpublic: virtual ~CMyButton(); // Generated message map functionsprotected: //{{AFX_MSG(CMyButton) afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void ParentNotify(UINT message, LPARAM lParam); //}}AFX_MSG DECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYBUTTON_H__7C6D5CAA_A730_4F48_835F_956D31ECA192__INCLUDED_)// MyButton.cpp : implementation file//#include "stdafx.h"#include "MyView.h"#include "MyButton.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CMyButtonCMyButton::CMyButton(){}CMyButton::~CMyButton(){}BEGIN_MESSAGE_MAP(CMyButton, CButton) //{{AFX_MSG_MAP(CMyButton) ON_WM_MOUSEMOVE() ON_WM_PARENTNOTIFY_REFLECT() //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CMyButton message handlersvoid CMyButton::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CString str; str.Format("x=%d,y=%d",point.x,point.y); SetWindowText(str); CButton::OnMouseMove(nFlags, point);}void CMyButton::ParentNotify(UINT message, LPARAM lParam) { // TODO: Add your message handler code here }#if !defined(AFX_MYDLG_H__2BE49736_563A_4BAC_9388_62D53CF5473F__INCLUDED_)#define AFX_MYDLG_H__2BE49736_563A_4BAC_9388_62D53CF5473F__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000// MyDlg.h : header file//#include "mybutton.h"/////////////////////////////////////////////////////////////////////////////// CMyDlg dialogclass CMyDlg : public CDialog{// Constructionpublic: CMyDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data //{{AFX_DATA(CMyDlg) enum { IDD = IDD_DIALOG1 }; CMyButton m_button; //}}AFX_DATA// Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMyDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL// Implementationprotected: // Generated message map functions //{{AFX_MSG(CMyDlg) afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); //}}AFX_MSG DECLARE_MESSAGE_MAP()};//{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYDLG_H__2BE49736_563A_4BAC_9388_62D53CF5473F__INCLUDED_)// MyDlg.cpp : implementation file//#include "stdafx.h"#include "MyView.h"#include "mybutton.h"#include "MyDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CMyDlg dialogCMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) : CDialog(CMyDlg::IDD, pParent){ //{{AFX_DATA_INIT(CMyDlg) //}}AFX_DATA_INIT}void CMyDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDlg) DDX_Control(pDX, IDC_BUTTON2, m_button); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CMyDlg, CDialog) //{{AFX_MSG_MAP(CMyDlg) ON_WM_SHOWWINDOW() //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CMyDlg message handlersvoid CMyDlg::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); // TODO: Add your message handler code here //ShowWindow(SW_SHOWMAXIMIZED);} COM组件如何避免结构体重复定义 vc 自定义控件 VC/MFC中的MDI程序,如何判断已经打开了子窗体,而不需要重新创建? Activex内部控件子类化问题(高手呢) 如何在一个窗口中打开另一个窗口? 关于vc版本的两个问题,立即结帐!谢谢! 各位大哥帮助!为什么会出现必须先telnet服务器端口,客户端socket才能连接成功的情况? 如何让对话框有缩放功能?里面的控件也同时缩放 关于VC的小问题 如何向通过应用程序向IE的当前网页中的文本框中添入信息?急!!!高分相增! 请各位帮忙,一个定时弹出提示窗口的程序! 請教:
point.x = LOWORD(lParam);
point.y = HIWORD(lParam);
rect = GetWindowRect(hButtuon,&rect);
ClientToScreen(hwnd,&point);
有问题吗?可就是不行啊!
代码有13000行的超cool表格程序,如何开发成activeX控件,有兴趣的人留下email,我把源程序发给你们
分数为150分
十万火级,如能给出答案,再送300分
有兴趣的人留下email
我把程序发给你们。
一个很cool的表格程序,请问如何改为activeX控件,有兴趣的我把源代码发给你们,感兴趣的人留下email,
是vc写的非常cool
实际上就是SDK中调用SETWINDOWLONG,见MFC\SRC\WINCORE.CPP中的函数实现。
#if !defined(AFX_MYBUTTON_H__7C6D5CAA_A730_4F48_835F_956D31ECA192__INCLUDED_)
#define AFX_MYBUTTON_H__7C6D5CAA_A730_4F48_835F_956D31ECA192__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyButton.h : header file
///////////////////////////////////////////////////////////////////////////////
// CMyButton windowclass CMyButton : public CButton
{
// Construction
public:
CMyButton();// Attributes
public:// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyButton)
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CMyButton(); // Generated message map functions
protected:
//{{AFX_MSG(CMyButton)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void ParentNotify(UINT message, LPARAM lParam);
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYBUTTON_H__7C6D5CAA_A730_4F48_835F_956D31ECA192__INCLUDED_)
// MyButton.cpp : implementation file
//#include "stdafx.h"
#include "MyView.h"
#include "MyButton.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMyButtonCMyButton::CMyButton()
{
}CMyButton::~CMyButton()
{
}
BEGIN_MESSAGE_MAP(CMyButton, CButton)
//{{AFX_MSG_MAP(CMyButton)
ON_WM_MOUSEMOVE()
ON_WM_PARENTNOTIFY_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyButton message handlersvoid CMyButton::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("x=%d,y=%d",point.x,point.y);
SetWindowText(str);
CButton::OnMouseMove(nFlags, point);
}void CMyButton::ParentNotify(UINT message, LPARAM lParam)
{
// TODO: Add your message handler code here
}#if !defined(AFX_MYDLG_H__2BE49736_563A_4BAC_9388_62D53CF5473F__INCLUDED_)
#define AFX_MYDLG_H__2BE49736_563A_4BAC_9388_62D53CF5473F__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyDlg.h : header file
//
#include "mybutton.h"
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialogclass CMyDlg : public CDialog
{
// Construction
public:
CMyDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
//{{AFX_DATA(CMyDlg)
enum { IDD = IDD_DIALOG1 };
CMyButton m_button;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected: // Generated message map functions
//{{AFX_MSG(CMyDlg)
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYDLG_H__2BE49736_563A_4BAC_9388_62D53CF5473F__INCLUDED_)// MyDlg.cpp : implementation file
//#include "stdafx.h"
#include "MyView.h"
#include "mybutton.h"
#include "MyDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
//}}AFX_DATA_INIT
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDC_BUTTON2, m_button);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlersvoid CMyDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
//ShowWindow(SW_SHOWMAXIMIZED);
}