fix not deleting timer when auto window has been closed.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1041 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com 2010-11-06 04:21:19 +00:00
parent dda2cd7254
commit 523980b430
1 changed files with 18 additions and 0 deletions

View File

@ -61,6 +61,21 @@ void diag_close(struct rtgui_timer* timer, void* parameter)
}
}
/* AUTO窗口关闭时的事件处理 */
rt_bool_t auto_window_close(struct rtgui_widget* widget, struct rtgui_event* event)
{
if (timer != RT_NULL)
{
/* 停止并删除定时器 */
rtgui_timer_stop(timer);
rtgui_timer_destory(timer);
timer = RT_NULL;
}
return RT_TRUE;
}
static rt_uint16_t delta_x = 20;
static rt_uint16_t delta_y = 40;
@ -115,6 +130,9 @@ static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* ev
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(msgbox), RTGUI_WIDGET(label));
/* 设置关闭窗口时的动作 */
rtgui_win_set_onclose(msgbox, auto_window_close);
rtgui_win_show(msgbox, RT_FALSE);
}