From 523980b43063d6c922cc359e545bedd2b863db2a Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Sat, 6 Nov 2010 04:21:19 +0000 Subject: [PATCH] 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 --- examples/gui/demo_view_window.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/gui/demo_view_window.c b/examples/gui/demo_view_window.c index abf601a932..2cbb9b9a57 100644 --- a/examples/gui/demo_view_window.c +++ b/examples/gui/demo_view_window.c @@ -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); }