新手上路
- 积分
- 24
- 金钱
- 24
- 注册时间
- 2022-5-7
- 在线时间
- 5 小时
|
1、实验条件
STemWin stm32F407 ICONView2、制作了多个图标与对应的对话框
3、第一次点击图标可以打开对话框,
4、问题:关闭对话框后,再点击图标,就没有用了
//--------------------- Function Prototype ----------------------//
void MainTask(void);
//--------------------------- Variable --------------------------//
static WM_HWIN h_window;
static WM_HWIN h_iconview;
static WM_HWIN h_button0,h_button1,h_button2,h_button3;
static WM_HWIN h_frame;
static int bkcolor,selcolor,textcolor;
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 25, 200, 215, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", ID_BUTTON_4, 20, 100, 80, 30, 0, 0x0, 0 },
};
//--------------------------- Function --------------------------//
/*
* Name : _cbDialog
* Description : ---
* Author : zh.
*
* History
* --------------------
* Rev : 0.00
* Date : 02/08/2017
*
* create.
* --------------------
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetTitleHeight(hItem, 40);
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
// FRAMEWIN_SetFont(hItem, &GUI_FontHZ16);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4);
// BUTTON_SetFont(hItem, &GUI_FontHZ16);
BUTTON_SetText(hItem, "return");
break;
case WM_PAINT:
// GUI_SetFont(&GUI_FontHZ16);
GUI_SetColor(GUI_BLACK);
GUI_DispStringHCenterAt("No content", 50, 20);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_4:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
GUI_EndDialog(h_frame,0);
break;
case WM_NOTIFICATION_RELEASED:
//GUI_EndDialog(h_frame,0);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*
* Name : _cbBkWindow
* Description : ---
* Author : zh.
*
* History
* --------------------
* Rev : 0.00
* Date : 02/08/2017
*
* create.
* --------------------
*/
static void _cbBkWindow(WM_MESSAGE * pMsg)
{
int NCode;
int Id;
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(0x00CECECE);
GUI_Clear();
GUI_SetColor(GUI_BLUE);
// GUI_SetFont(&GUI_FontFixedsys16);
GUI_DispStringHCenterAt("WIDGET_Iconview - Sample", 10, 5);
break;
//case WM_TOUCH_CHILD:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(NCode){
case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
switch(Id){
case ID_BUTTON_0:
if(!bkcolor){
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_BK,GUI_LIGHTRED);
}else{
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_BK,GUI_LIGHTMAGENTA);
}
bkcolor ^= 1;
break;
case ID_BUTTON_1:
if(!selcolor){
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_SEL,GUI_RED);
}else{
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_SEL,GUI_BLUE);
}
selcolor ^= 1;
break;
case ID_BUTTON_2:
if(!textcolor){
ICONVIEW_SetTextColor(h_iconview,ICONVIEW_CI_SEL,GUI_BLACK);
}else{
ICONVIEW_SetTextColor(h_iconview,ICONVIEW_CI_SEL,GUI_WHITE);
}
textcolor ^= 1;
break;
case ID_BUTTON_3:
if(selcolor){
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_SEL,GUI_RED | 0x80000000);
}else{
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_SEL,GUI_BLUE | 0x80000000);
}
break;
case ID_ICONVIEW_0:
switch(ICONVIEW_GetSel(pMsg->hWinSrc)){
case 0:
h_frame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, h_window, 0, 0);
FRAMEWIN_SetText(h_frame,"Canlender");
break;
case 1:
h_frame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, h_window, 0, 0);
FRAMEWIN_SetText(h_frame,"ComPass");
break;
case 2:
h_frame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, h_window, 0, 0);
FRAMEWIN_SetText(h_frame,"Light");
break;
case 3:
h_frame = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, h_window, 0, 0);
FRAMEWIN_SetText(h_frame,"DownLoad");
break;
}
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
//static void _cbICON(WM_MESSAGE * pMsg)
//{
// int NCode;
// int Id;
//
// switch (pMsg->MsgId)
// {
// case WM_PAINT:
// GUI_SetBkColor(0x00CECECE);
// GUI_Clear();
// GUI_SetColor(GUI_BLUE);
// GUI_DispStringHCenterAt("WIDGET_Iconview - Sample", 10, 5);
// break;
//
// //case WM_TOUCH_CHILD:
// case WM_NOTIFY_PARENT:
// Id = WM_GetId(pMsg->hWinSrc);
// NCode = pMsg->Data.v;
//// switch(NCode){}
// break;
// }
//}
/*
* Name : create_iconview
* Description : ---
* Author : zh.
*
* History
* --------------------
* Rev : 0.00
* Date : 02/08/2017
*
* create.
* --------------------
*/
static void create_window(void)
{
h_window = WM_CreateWindow( 0, 0, 220, 300, WM_CF_SHOW, _cbBkWindow, 0);
}
/*
* Name : create_edit
* Description : ---
* Author : zh.
*
* History
* --------------------
* Rev : 0.00
* Date : 02/08/2017
*
* create.
* --------------------
*/
static void create_iconview(void)
{
//h_iconview = ICONVIEW_CreateEx(0, 10, 210, 300, h_window,WM_CF_SHOW,0,ID_ICONVIEW_0,90,100);
h_iconview = ICONVIEW_CreateEx(0, /* 小工具的最左像素(在父坐标中)*/
0, /* 小工具的最上像素(在父坐标中)*/
240, /* 小工具的水平尺寸(单位:像素)*/
320, /* 小工具的垂直尺寸(单位:像素)*/
h_window, /* 父窗口的句柄。如果为0 ,则新小工具将成为桌面(顶级窗口)的子窗口 */
WM_CF_SHOW | WM_CF_HASTRANS, /* 窗口创建标记。为使小工具立即可见,通常使用 WM_CF_SHOW */
0, //ICONVIEW_CF_AUTOSCROLLBAR_V, /* 默认是0,如果不够现实可设置增减垂直滚动条 */
ID_ICONVIEW_0, /* 小工具的窗口ID */
80, /* 图标的水平尺寸 */
80);/* 图标的垂直尺寸 */
ICONVIEW_SetIconAlign(h_iconview, ICONVIEW_IA_HCENTER|ICONVIEW_IA_TOP);
ICONVIEW_SetBkColor(h_iconview,ICONVIEW_CI_BK,GUI_LIGHTMAGENTA);
// ICONVIEW_SetFont(h_iconview,&GUI_FontHZ16);
ICONVIEW_AddBitmapItem(h_iconview,&bmbmp_1,"Calender");
ICONVIEW_AddBitmapItem(h_iconview,&bmbmp_2,"Compass");
ICONVIEW_AddBitmapItem(h_iconview,&bmbmp_3,"Light");
ICONVIEW_AddBitmapItem(h_iconview,&bmbmp_4,"DownLoad");
//WM_SetCallback(h_iconview,_cbICON);
}
/*
* Name : create_button
* Description : ---
* Author : zh.
*
* History
* --------------------
* Rev : 0.00
* Date : 02/08/2017
*
* create.
* --------------------
*/
static void create_button(void)
{
h_button0 = BUTTON_CreateEx(160, 25, 60, 40, h_window, WM_CF_SHOW, 0, ID_BUTTON_0);
// BUTTON_SetFont(h_button0, &GUI_FontFixedsys16);
BUTTON_SetText(h_button0, "BkColor");
h_button1 = BUTTON_CreateEx(160, 65, 60, 40, h_window, WM_CF_SHOW, 0, ID_BUTTON_1);
// BUTTON_SetFont(h_button1, &GUI_FontFixedsys16);
BUTTON_SetText(h_button1, "SelColor");
h_button2 = BUTTON_CreateEx(160, 105, 60, 40, h_window, WM_CF_SHOW, 0, ID_BUTTON_2);
// BUTTON_SetFont(h_button2, &GUI_FontFixedsys16);
BUTTON_SetText(h_button2, "TextColor");
h_button3 = BUTTON_CreateEx(160, 145, 60, 40, h_window, WM_CF_SHOW, 0, ID_BUTTON_3);
// BUTTON_SetFont(h_button3, &GUI_FontFixedsys16);
BUTTON_SetText(h_button3, "Alpha");
}
/*********************************************************************
*
* MainTask
*
* Demonstrates a dialog box
*
**********************************************************************
*/
void MainTask(void) {
WM_SetCreateFlags(WM_CF_MEMDEV);
create_window();
create_iconview();
create_button();
while (1)
{
GUI_Delay(10);//GUI_Exec();
GUI_TOUCH_Exec();//触摸屏定时扫描
}
}
|
|