当前位置:
凯发ag旗舰厅登录网址下载 >
编程资源
> 编程问答
>内容正文
编程问答
emwin自定义消息问题 -凯发ag旗舰厅登录网址下载
凯发ag旗舰厅登录网址下载
收集整理的这篇文章主要介绍了
emwin自定义消息问题
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
例如我要定义一个wm_ic的消息
1.在emwin窗口文件的头文件.h文件中声明 #define wm_ic (wm_user 0x00)//自定义消息
2.然后在 switch (pmsg->msgid) {....}中定义一个case wm_ic:...break;
然后就是想在地方产生此消息用wm_sendmessagenopara(wm_getclientwindow(hdlg),wm_ic)即可
其中wm_getclientwindow为返回客户端窗口句柄。具体在《emwin5中文手册》窗口管理器(wm)中14.5wm api这一节中。
#include "dialog.h" #include "3ddlg.h" #include "emwinhzfont.h" #include "shezhi_windlg.h" #include "delay.h" #include "led.h" #include "rc522.h" #include "tftlcd.h" #include "ltdc.h"/********************************************************************* * * defines * ********************************************************************** */ #define id_framewin_0 (gui_id_user 0x00) #define id_button_1 (gui_id_user 0x01)//设置 3 #define id_button_2 (gui_id_user 0x02)//凯发ag旗舰厅登录网址下载主页 4 #define id_button_3 (gui_id_user 0x03)//配置 5#define id_button_4 (gui_id_user 0x04)//状态 1 #define id_button_5 (gui_id_user 0x05)//位置 2 #define id_button_6 (gui_id_user 0x06)//位置 2#define id_text_1 (gui_id_user 0x07)//打印机温度 #define id_text_2 (gui_id_user 0x08)//打印机温度 #define id_text_3 (gui_id_user 0x09)//打印机温度static int m=1,n=0;//m为行,n为列 button_skinflex_props props1; u8 flag1=1,flag2=1,flag3=1; char ic_buf0[2]; char ic_buf1[2]; char ic_buf2[2]; char ic_buf3[2]; /**********外部变量声明***************/ extern u16 info; extern unsigned char ic_sn[4]; //卡号 extern u8 rs485buf[80]; extern u8 show_ic; /**********外部变量声明***************/const framewin_skinflex_props pprops={ gui_white,gui_white,gui_white,gui_white,gui_white, 0,5,5,5,1,5,};static const gui_widget_create_info _adialogcreate[] = {{ framewin_createindirect, "3d", id_framewin_0, 0, 0, 480, 272, 0, 0x0, 0 },{ button_createindirect, "button", id_button_1, 0, 0, 470, 86, 0, 0x0, 0 },//{ button_createindirect, "button", id_button_2, 160, 86, 160, 87, 0, 0x0, 0 },//{ button_createindirect, "button", id_button_3, 320, 86, 160, 87, 0, 0x0, 0}, //{ button_createindirect, "button", id_button_4, 0, 173, 160, 62, 0, 0x0, 0 },//{ button_createindirect, "button", id_button_5, 160, 173, 160, 62, 0, 0x0, 0 },//{ button_createindirect, "button", id_button_6, 320, 173, 160, 62, 0, 0x0, 0},//{ text_createindirect, "text", id_text_1, 60, 20, 26, 20, 0, 0x64, 0 }, { text_createindirect, "text", id_text_2, 80, 20, 160, 50, 0, 0x0, 0 },{ text_createindirect, "text", id_text_3, 310, 55, 26, 20, 0, 0x64, 0 }, };static void _cbdialog(wm_message * pmsg) {wm_hwin hitem,hitem1,hitem2,hitem3,hitem4,hitem5;wm_hwin htext1,htext2,htext3;hitem1= wm_getdialogitem(pmsg->hwin, id_button_1); hitem2= wm_getdialogitem(pmsg->hwin, id_button_2);hitem3= wm_getdialogitem(pmsg->hwin, id_button_3);hitem4= wm_getdialogitem(pmsg->hwin, id_button_5);hitem5= wm_getdialogitem(pmsg->hwin, id_button_6);htext1=wm_getdialogitem(pmsg->hwin, id_text_1);htext2=wm_getdialogitem(pmsg->hwin, id_text_2); htext3=wm_getdialogitem(pmsg->hwin, id_text_3);wm_hwin xz_hitem[2][2]={hitem2,hitem3,hitem4,hitem5};//button1,int ncode;int id;switch (pmsg->msgid) {case wm_init_dialog:hitem = pmsg->hwin;framewin_setskinflexprops(&pprops,framewin_skinflex_pi_active);button_getskinflexprops(&props1, button_skinflex_pi_focussed);props1.acolorframe[0] = 0x007fb13c;props1.acolorframe[1] = 0x008fff8f;props1.acolorframe[2] = 0x008fff8f;props1.acolorupper[0]=0x008fff8f;props1.acolorupper[1]=0x008fff8f;props1.acolorlower[0]=0x008fff8f;props1.acolorlower[1]=0x008fff8f;props1.radius = 6;button_setskinflexprops(&props1, button_skinflex_pi_focussed);//被选中之后的颜色framewin_settextcolor(hitem,gui_black);framewin_settextalign(hitem, gui_ta_left);framewin_settitleheight(hitem, 30);framewin_setfont(hitem, &gui_fonthz24);framewin_settext(hitem, "welcome");text_setfont(htext1, &gui_font16b_1);text_settext(htext1,"id:");text_setfont(htext2, &gui_font16b_1); text_settext(htext2," "); //初始化button1 hitem = wm_getdialogitem(pmsg->hwin, id_button_1);button_settext(hitem, "");//初始化button2hitem = wm_getdialogitem(pmsg->hwin, id_button_2);wm_setfocus(hitem2);button_settext(hitem, "");// //初始化button3hitem = wm_getdialogitem(pmsg->hwin,id_button_3);button_setfocussable(hitem,1);button_settext(hitem, "");//初始化 button4// hitem = wm_getdialogitem(pmsg->hwin, id_button_4);button_settext(hitem, ""); //初始化button5hitem = wm_getdialogitem(pmsg->hwin, id_button_5);button_settext(hitem, ""); //初始化button6hitem = wm_getdialogitem(pmsg->hwin, id_button_6);button_settext(hitem, ""); break;case wm_key://按键控制switch (((wm_key_info*)(pmsg->data.p))->key) {case gui_key_up:m--;if(m<0) m=0;wm_setfocus(xz_hitem[m][n]);break;case gui_key_down:m ;if(m>1) m=1;wm_setfocus(xz_hitem[m][n]);break;case gui_key_left:n--;if(n<0) n=0;wm_setfocus(xz_hitem[m][n]);break;case gui_key_right:n ;if(n>1) n=1;wm_setfocus(xz_hitem[m][n]);break;case gui_key_end:gui_enddialog(pmsg->hwin, 0);createsehzhi_win();}break;case wm_ic:if(show_ic){sprintf((char*)ic_buf0,"%0x",ic_sn[0]);sprintf((char*)ic_buf1,"%0x",ic_sn[1]);sprintf((char*)ic_buf2,"%0x",ic_sn[2]);sprintf((char*)ic_buf3,"%0x",ic_sn[3]);text_setfont(htext1, &gui_font16b_1);text_settext(htext1,"id:");text_setfont(htext2, &gui_font16b_1); text_settext(htext2,ic_buf0); }else{text_settext(htext1,"id:");text_settext(htext2," ");}break;default:wm_defaultproc(pmsg);break;}}/********************************************************************* * * public code * ********************************************************************** */ /********************************************************************* * * create3d */ wm_hwin create3d(void) {wm_hwin hwin; hwin = gui_createdialogbox(_adialogcreate,gui_countof(_adialogcreate),_cbdialog, wm_hbkwin,0,0);return hwin; }// user start (optionally insert additional public code) // user end/*************************** end of file ****************************/
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的emwin自定义消息问题的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇: 显示屏的方向设置问题
- 下一篇: 28 march 2019