打印
[应用相关]

emWin_IconView图标控件使用方法

[复制链接]
2850|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主

(1)使用GUIBuilder V5.30创建如下页面并保存为C文件FramewinDLG.c,然后添加到脱机模拟仿真平台CodeBlocks的emwin工程:



(2)用BmpCvt.exe(可在”软件/资料下载”栏目下载)将48×48的图标PNG文件转成C文件并添加到CodeBlocks工程:



(3)在生成的FramewinDLG.c文件中需要更改图标的大小为64×64:


(4)在WM_INIT_DIALOG消息中(窗口初始化时程序跑到这里)添加ICONVIEW控件的初始化代码:

......

hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_0);

ICONVIEW_SetIconAlign(hItem, ICONVIEW_IA_TOP);

ICONVIEW_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_BLUE);

ICONVIEW_SetTextColor(hItem, ICONVIEW_CI_SEL, GUI_GREEN);

ICONVIEW_SetFrame(hItem, GUI_COORD_X, 0);//设置图标到IconView边框的间距

ICONVIEW_SetFrame(hItem, GUI_COORD_Y, 0);

ICONVIEW_SetSpace(hItem, GUI_COORD_X, (280-64*4)/3);//设置图标和图标之间的间距

ICONVIEW_SetSpace(hItem, GUI_COORD_Y, (140-64*2)/1);

ICONVIEW_SetFont(hItem, GUI_FONT_16_1);

ICONVIEW_AddBitmapItem(hItem, &bm01, "neqee");//添加图标项

ICONVIEW_AddBitmapItem(hItem, &bm02, "SOS");

ICONVIEW_AddBitmapItem(hItem, &bm03, "Phone");

ICONVIEW_AddBitmapItem(hItem, &bm04, "Camera");

ICONVIEW_AddBitmapItem(hItem, &bm05, "Email");

ICONVIEW_AddBitmapItem(hItem, &bm06, "NoteBook");

ICONVIEW_AddBitmapItem(hItem, &bm07, "JTV");

ICONVIEW_AddBitmapItem(hItem, &bm08, "Dollar");

......



(5) WM_NOTIFY_PARENT消息中(操作屏幕时程序跑到这里)添加点击提示程序:

switch(ICONVIEW_GetSel(WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_0)))

{

case 0: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "neqee"); break;

case 1: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "SOS"); break;

case 2: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "Phone"); break;

case 3: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "Camera"); break;

case 4: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "Email"); break;

case 5: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "NoteBook"); break;

case 6: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "JTV"); break;

case 7: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "Dollar"); break;

//case 8: TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), "Jobbet"); break;

}


沙发
天灵灵地灵灵|  楼主 | 2017-8-10 17:02 | 只看该作者

(6)编译运行:



使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

174

主题

3361

帖子

13

粉丝