调用所有者定义控件的用户定义的事件处理程序 [英] Calling user defined event handler for owner draw control

查看:68
本文介绍了调用所有者定义控件的用户定义的事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

这可能是一个愚蠢的问题,是整个假期期间过度放纵的结果.无论如何,这里都是这样:我已经创建了一个所有者绘制按钮(CButtonEx),并且添加的许多功能之一是具有超时时间的功能,该时间耗尽后将导致执行用户定义的OnClick函数.我可以在CButtonEx源文件中放置onclick处理程序,并可以在CButtonEx类中调用它,也可以在放置按钮的Dialog类中放置onclick处理程序.并且可以从对话框OnClick调用CButtonEx OnClick.

你怎么叫那棵树?即从CbuttonEx到用户代码所在的CDialog类???我敢肯定,以为您可以发布一条消息应该很简单,但是我认为这比这更容易.

任何帮助,不胜感激.

Andy

Hi All

This may be a stupid question and the result of over-indulgence throughout the holiday period. Anyway here goes : I have created an owner draw button (CButtonEx) and one of the many features added is the ability to have a timeout period which when depleted causes the user-defined OnClick function to execute. I can put an onclick handler in the CButtonEx source file and can call that from within the CButtonEx class, I can also put an on click handler in the Dialog class where the button is placed. And can call the CButtonEx OnClick from the Dialog OnClick.

How do you call down the tree?? i.e. from the CbuttonEx to the CDialog class where the user code is??? I am sure this should be simple was thinking that you could post a message but I think that it sould be easier than that.

Any help greatly appreciated.

Andy

推荐答案

在您的CButtonEx OnTimer()处理程序中:
::PostMessage(GetParent()->m_hWnd, WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd);

欢呼声,
AR
In your CButtonEx OnTimer() handler:
::PostMessage(GetParent()->m_hWnd, WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd);

cheers,
AR


这在.NET中是微不足道的,但是我相信在C ++中,您需要使用函数指针在一个类中定义一个方法,然后在另一个类中调用一个方法.或者,您也可以使用消息,它可能更简单.
This is trivial in .NET, but I believe in C++ you need to use a function pointer to define a method in one class and then have it call a method in another. Or you could use messages, that may be simpler.


我会模仿MFC行为,即发布一条消息.
:)
I would mimic the MFC behaviour, i.e. post a message.
:)


这篇关于调用所有者定义控件的用户定义的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆