读书人

mfc 响应鼠标举起 Spin控件

发布时间: 2012-12-22 12:05:06 作者: rapoo

mfc 响应鼠标抬起 Spin控件
本帖最后由 m_hacker18 于 2012-11-13 17:48:31 编辑 做了一个Spin(就是带上下箭头的按钮)控件关联一个edit

要求 :当鼠标从Spin上抬起后,发送消息给父窗口

1 我想响应Spin的NM_ReleasedCapture消息,但是不知道该怎么写。。。

求高手

2 我还想通过重载CSpinButtonCtrl类为CMySpin类,
然后在CMySpin中响应LButtonUp消息,在响应函数中发消息,
::SendMessage(hwnd,wparam,lparam)
但是我不知道怎么捕获父窗口的句柄HWnd,
ps 我是在一个TabCtrl上放的Spin控件,
Tabctrl的类名为CDlg2

[最优解释]
HWND hwnd = NULL;

::GetParent(hwnd);

错了
CWnd *pDlg = GetParent();
pDlg->m_hWnd 是你要的。
你可以
pDlg-》SendMessage(。。。)

[其他解释]
希望 向版主 指导。。。
[其他解释]
自己顶。。。
[其他解释]
"当鼠标从Spin上抬起后"
当鼠标从Spin的按钮上抬起后?
[其他解释]
当鼠标从Spin的按钮上抬起后?

是的
[其他解释]

引用:
"当鼠标从Spin上抬起后"
当鼠标从Spin的按钮上抬起后?


是的

求关注
[其他解释]
CMySpin 是 对话框的 子窗口, 所以:
GetParent();就得到 对话框了。
[其他解释]
引用:
CMySpin 是 对话框的 子窗口, 所以:
GetParent();就得到 对话框了。


刚刚试过

我在自己重写的CMySpin类LButtonUp的响应函数中

HWND hwnd;

::Getparent(hwnd); // F5运行后,停在这里

::SendMessage(hwnd,wparam,lparam);


[其他解释]
引用:
CMySpin 是 对话框的 子窗口, 所以:
GetParent();就得到 对话框了。


这个方法只是我的无奈之举,

个人觉得 响应 spinbuttonctrl 的 NM_ReleasedCapture 消息 最直接。


[其他解释]
引用:
CMySpin 是 对话框的 子窗口, 所以:
GetParent();就得到 对话框了。


HWND hwnd = NULL;

::GetParent(hwnd);

if(hwnd == NULL)

AfxMessagebox("Fault");

else

::SendMessage(hwnd,0,0);


结果hwnd为NULL,弹出Fault消息框

是我获取父对话框句柄由错么?
[其他解释]
"个人觉得 响应 spinbuttonctrl 的 NM_ReleasedCapture 消息 最直接。"
spin 点击时,并没有 SetCapture ,鼠标离开按钮就 没用了。
[其他解释]
引用:
HWND hwnd = NULL;

::GetParent(hwnd);

错了
CWnd *pDlg = GetParent();
pDlg->m_hWnd 是你要的。
你可以
pDlg-》SendMessage(。。。)


给分

刚才看了下面的文章有些收获,顺便分享下
http://blog.csdn.net/chinagdlex/article/details/6899605

读书人网 >VC/MFC

热点推荐