完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我用IMAGE控件做按钮利用IMAGE触摸事件处理任务目前遇到困难,
#include "home.h" #define ID_SET_TOUCH (ID_SET_BASE + 1) #define ID_SET_tiME (ID_SET_BASE + 2) #define ID_SET_BKIMAGE (ID_SET_BASE + 3) #define ID_SET_HELP (ID_SET_BASE + 4) #define ID_SET_EXIT (ID_SET_BASE + 5) IMAGE_Handle SET_hImage[5]; static void _cbDialog(WM_MESSAGE * pMsg) { static bool app=false; int i; FIL bmp; switch(pMsg ->MsgId) { case WM_PAINT: //重绘 if(app==false) { f_open(&bmp,"picture/home/1.bmp",FA_READ); GUI_BMP_DrawEx(_Get_BackImage,(void *)&bmp,0,20); //这里重绘的是背景图片,可以正常显示背景 f_close(&bmp); f_open(&bmp,"picture/set/touch/touch.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[0],_Get_BackImage,(void *)&bmp); //这里重绘第一个IMAGE图标,不能显示 f_close(&bmp); f_open(&bmp,"picture/set/time/time.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[1],_Get_BackImage,(void *)&bmp); //第二个图标也不能显示 f_close(&bmp); f_open(&bmp,"picture/set/bkimage/bkimage.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[2],_Get_BackImage,(void *)&bmp); //以下都不能显示 f_close(&bmp); f_open(&bmp,"picture/set/help/help.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[3],_Get_BackImage,(void *)&bmp); f_close(&bmp); f_open(&bmp,"picture/set/exit/exit.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[4],_Get_BackImage,(void *)&bmp); f_close(&bmp); } break; case WM_NOTIFY_PARENT: switch(WM_GetId(pMsg ->hWinSrc)) { case ID_SET_TOUCH: //触摸校准 switch(pMsg ->Data.v) { case WM_NOTIFICATION_CLICKED: f_open(&bmp,"picture/set/touch/_touch.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[0],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; case WM_NOTIFICATION_RELEASED: app =true; for(i=0;i<5;i++) WM_DeleteWindow(SET_hImage); IS_Touch(true); Create_SetDesktop(); app =false; break; } break; case ID_SET_TIME: //时间设置 switch(pMsg ->Data.v) { case WM_NOTIFICATION_CLICKED: f_open(&bmp,"picture/set/time/_time.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[1],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; case WM_NOTIFICATION_RELEASED: f_open(&bmp,"picture/set/time/time.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[1],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; } break; case ID_SET_BKIMAGE: //背景图片 switch(pMsg ->Data.v) { case WM_NOTIFICATION_CLICKED: f_open(&bmp,"picture/set/bkimage/_bkimage.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[2],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; case WM_NOTIFICATION_RELEASED: f_open(&bmp,"picture/set/bkimage/bkimage.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[2],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; } break; case ID_SET_HELP: //帮助 switch(pMsg ->Data.v) { case WM_NOTIFICATION_CLICKED: f_open(&bmp,"picture/set/help/_help.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[3],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; case WM_NOTIFICATION_RELEASED: f_open(&bmp,"picture/set/help/help.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[3],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; } break; case ID_SET_EXIT: //返回 switch(pMsg ->Data.v) { case WM_NOTIFICATION_CLICKED: f_open(&bmp,"picture/set/exit/_exit.bmp",FA_READ); IMAGE_SetBMPEx(SET_hImage[4],_Get_BackImage,(void *)&bmp); f_close(&bmp); break; case WM_NOTIFICATION_RELEASED: app =false; for(i=0;i<5;i++) WM_DeleteWindow(SET_hImage); Create_HomeDesktop(); break; } break; } break; default: WM_DefaultProc(pMsg); break; } } void Create_SetDesktop() //这里是创建5个IMAGE控件,然后在消息中设置IMAGE的bmp图片 { WM_SetCallback(WM_HBKWIN,_cbDialog); SET_hImage[0]= IMAGE_CreateEx(0, 20,240,30,WM_HBKWIN,WM_CF_SHOW,IMAGE_CF_TILE,ID_SET_TOUCH); SET_hImage[1]= IMAGE_CreateEx(0, 50,240,30,WM_HBKWIN,WM_CF_SHOW,IMAGE_CF_TILE,ID_SET_TIME); SET_hImage[2]= IMAGE_CreateEx(0, 80,240,30,WM_HBKWIN,WM_CF_SHOW,IMAGE_CF_TILE,ID_SET_BKIMAGE); SET_hImage[3]= IMAGE_CreateEx(0,110,240,30,WM_HBKWIN,WM_CF_SHOW,IMAGE_CF_TILE,ID_SET_HELP); SET_hImage[4]= IMAGE_CreateEx(0,140,240,30,WM_HBKWIN,WM_CF_SHOW,IMAGE_CF_TILE,ID_SET_EXIT); } 现在程序的状态是开机显示主界面,主界面有很多图标其中的设置图标被点击后调用Create_SetDesktop()切换到设置界面,设置界面就会创建以上5个IMAGE图标(用来做按钮),但是切换后只显示背景图片,IMAGE的BMP图标都没有显示出来,我在相应位置触摸是可以正常进入下一级菜单(本级菜单分别是触摸校验/时间设置/背景图片设置/帮助/返回),比如在触摸校验的位置触摸就可以正常进入触摸校验程序、触摸返回的位置就正常返回到了主界面,从这点可以说明IMAGE控件是正常被创建了,而且消息可以正常处理就是加载的图标不显示,请大家帮我看看是为什么?是不是IMAGE的控件少了哪些设置?我调试了IMAGE控件创建正常返回了句柄,f_open也正常读到了数据,就是 IMAGE_SetBMPEx()函数不能显示,如果我把IMAGE_SetBMPEx()全部换成GUI_BMP_DrawEx()就可以正常显示所有图标,但是这么做程序编写就不规范了。 |
|
相关推荐
4个回答
|
|
|
|
已经解决了。
|
|
|
|
楼主怎么解决的 能说一下吗 谢谢
|
|
|
|
你也是用Image显示图片吗?如果是的话那么Image是控件不是直接的绘制函数,所以当使用控件显示图片时系统是不会立马显示的同时给定绘制函数的文件句柄或说路径要一直保持有效,当屏幕需要刷新时Image控件会自动刷新显示。
|
|
|
|
只有小组成员才能发言,加入小组>>
698 浏览 0 评论
1109 浏览 1 评论
2476 浏览 5 评论
2810 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2653 浏览 6 评论
使用eim外接fpga可是端口一点反应都没有有没有大哥指点一下啊
656浏览 9评论
651浏览 7评论
请教大神怎样去解决iMX6Q在linux3.0.35内核上做AP失败的问题呢
784浏览 6评论
632浏览 5评论
672浏览 5评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 02:20 , Processed in 1.245592 second(s), Total 86, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号