|
也有野路子的,比如是直接用类指针作为时钟ID,然后在回调里将时钟ID还原为类指针去调用类动态方法。
<火山程序 类型 = "通常" 版本 = 1 />
类 窗口时钟类 <公开 折叠>
{
方法 类_清理 <折叠>
{
结束时钟 ()
}
方法 启动时钟 <公开 类型 = 逻辑型 注释 = "启动时钟,重复启动将替换之前的时钟,可以当作是修改周期时间." 折叠 @禁止流程检查 = 真>
参数 窗口句柄 <类型 = 变整数 注释 = "请提供主窗口的句柄">
参数 周期时间 <类型 = 整数 注释 = "时钟运行的周期时间,以毫秒为单位">
{
@ m_hwnd = reinterpret_cast<HWND>(@<窗口句柄>);
@ return (::SetTimer(m_hwnd, reinterpret_cast<UINT_PTR>(this), static_cast<UINT>(@<周期时间>), &@sn<current_class_def>::Timerproc) != 0);
}
方法 结束时钟 <公开 类型 = 逻辑型 注释 = "结束时钟" 折叠 @禁止流程检查 = 真>
{
@ return ::KillTimer(m_hwnd, reinterpret_cast<UINT_PTR>(this));
}
方法 周期时间 <公开 属性写 注释 = "修改当前的周期时间" 折叠>
参数 周期时间 <类型 = 整数 注释 = "时钟运行的周期时间,以毫秒为单位">
{
@ if (m_hwnd != NULL)
@ ::SetTimer(m_hwnd, reinterpret_cast<UINT_PTR>(this), static_cast<UINT>(@<周期时间>), &@sn<current_class_def>::Timerproc);
}
方法 时钟事件 <公开 定义事件 类型 = 整数 注释 = "每当经过了指定的时钟周期,将发送本事件." 注释 = "注意: 本事件在主窗口的消息循环中执行,请勿执行耗时操作,否则会卡界面."
返回值注释 = "此返回值无意义" 折叠>
参数 窗口句柄 <类型 = 变整数 注释 = "返回与时钟关联的窗口句柄">
参数 启动时间 <类型 = 整数 注释 = "系统启动后经过的毫秒数,与\"取启动时间\"一致.">
# ---
# @begin
# <> <include>
# HWND m_hwnd = NULL;
# static VOID CALLBACK Timerproc (HWND hwnd, UINT message, UINT_PTR iTimerID, DWORD dwTime) {
# reinterpret_cast<@sn<current_class>*>(iTimerID)->@<时钟事件>(reinterpret_cast<INT_P>(hwnd), static_cast<INT>(dwTime));
# }
# <> </include>
# @end
# ---
}
|
|