高级会员
- 积分
- 972
- 金钱
- 972
- 注册时间
- 2016-6-15
- 在线时间
- 473 小时
|
6金钱
本帖最后由 shuaigew88 于 2016-9-2 09:12 编辑
大家好,我用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()就可以正常显示所有图标,但是这么做程序编写就不规范了。
|
|