emWin使用資料收集(一) ----- emWin 2天速成實例教程008_IconView圖標控件使用方法


備注:(1)打開工程目錄下的"Exe\GUISimulationDebug.exe"即可看到效果。(2)看完教程000~005就基本會用emWin做項目,其他章節可以需要時再參考。

(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消息中(操作屏幕時程序跑到這里)添加點擊IconView提示程序:

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;

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

}


(5)編譯運行:


轉自:


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com