typedef enum tagMSG
{
WM_NO_MSG,
WM_DESTORY,
//
按ESC销毁
WM_PAINT,
//
重画
WM_CREATE_NUMBER,
//
创建数字对话框
WM_CREATE_MENU,
//
创建下拉列表
WM_VALID,
//
确认
WM_SWITCH,
//
组态切换
WM_ERROR,
//
错误
WM_FLUSH,
//
刷新(当控制单位发生改变,
需要重新刷新上级菜单界面)
}MSG;
///////////////////////////////////////////////////////////////////////////////////////////////
//通用结构体(包括:运行、启动曲线、转速控制、负荷控制、#1阀控制、#2阀控制、转速测量
//功能键、串级控制、通讯控制、LCD液晶屏)
///////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tagGUI_COM
{
int *Value;
union
{
struct
{
int *Min;
int *Max;
int *Dot;
}Wnd;
struct
{
char **MENU_Name;
//
"允许","禁止"
int MENU_Max;
//
= 2
}MENU;
}Class;
}GUI_COM;
typedef struct tagGUI_SET_STRUCT
{
int Window_No;
//
窗口号
int Window_Max;
//
当前窗口参数个数
int DialogBox_Type;
//
对话框类型(数字对话框/下拉列表)
int *Enable;
//
是否允许编辑
char *Chinese_Name;
//
对话框中每项的中文名称
char *Unit_Name;
//
对话框中每项的单位名称
char **Help_Name;
//
帮助信息
union
{
GUI_COM COM;
//
相同的子项
GUI_DI DI;
//
不同的子项()
GUI_DO DO;
GUI_AI AI;
GUI_AO AO;
}Info;
}GUI_SET_STRUCT,*GUI_SET_STRUCT_PTR;
///////////////////////////////////////////////////////////////////////////////////////////////
//系统初始化
///////////////////////////////////////////////////////////////////////////////////////////////
void _Cdecl POPUP_GUI_SET_STRUCT_Init(void)
{
int i;
for (i = 0 ; i < POPUP_RUN_WINDOW_MAX ; i++)
{
GUI_RUN_STRUCT[i].Window_No = POPUP_RUN_WINDOW_NO;
GUI_RUN_STRUCT[i].Window_Max = POPUP_RUN_WINDOW_MAX;
GUI_RUN_STRUCT[i].DialogBox_Type = NUMBER_DIALOGBOX;
GUI_RUN_STRUCT[i].Chinese_Name = run_para_table[i].name;
GUI_RUN_STRUCT[i].Unit_Name = run_para_table[i].unit;
GUI_RUN_STRUCT[i].Enable = &run_para_table[i].Enable;
GUI_RUN_STRUCT[i]. = &run_para_table[i].data;
GUI_RUN_STRUCT[i]. = &run_para_table[i].data_min;
GUI_RUN_STRUCT[i]. = &run_para_table[i].data_max;
GUI_RUN_STRUCT[i]. = &run_para_table[i].type;
}
for (i = 0 ; i < POPUP_STARTUP_WINDOW_MAX ; i++)
{
GUI_STARTUP_STRUCT[i].Window_No = POPUP_STARTUP_WINDOW_NO;
GUI_STARTUP_STRUCT[i].Window_Max = POPUP_STARTUP_WINDOW_MAX;
GUI_STARTUP_STRUCT[i].DialogBox_Type = NUMBER_DIALOGBOX;
GUI_STARTUP_STRUCT[i].Chinese_Name = start_para_table[i].name;
GUI_STARTUP_STRUCT[i].Unit_Name = start_para_table[i].unit;
GUI_STARTUP_STRUCT[i].Enable = &start_para_table[i].Enable;
GUI_STARTUP_STRUCT[i]. = &start_para_table[i].data;
GUI_STARTUP_STRUCT[i]. = &start_para_table[i].data_min;
GUI_STARTUP_STRUCT[i]. = &start_para_table[i].data_max;
GUI_STARTUP_STRUCT[i]. = &start_para_table[i].type;
}
GUI_STARTUP_STRUCT[2].DialogBox_Type = MENU_DIALOGBOX;
GUI_STARTUP_STRUCT[2]. = 2;
GUI_STARTUP_STRUCT[2]. = GUI_Enable_Name;
GUI_STARTUP_STRUCT[5].DialogBox_Type = MENU_DIALOGBOX;
GUI_STARTUP_STRUCT[5]. = 2;
GUI_STARTUP_STRUCT[5]. = GUI_Enable_Name;
for (i = 0 ; i < POPUP_SPEED_WINDOW_MAX ; i++)
{
GUI_SPEED_STRUCT[i].Window_No = POPUP_SPEED_WINDOW_NO;
GUI_SPEED_STRUCT[i].Window_Max = POPUP_SPEED_WINDOW_MAX;
GUI_SPEED_STRUCT[i].DialogBox_Type = NUMBER_DIALOGBOX;
GUI_SPEED_STRUCT[i].Chinese_Name = speed_para_table[i].name;
GUI_SPEED_STRUCT[i].Unit_Name = speed_para_table[i].unit;
GUI_SPEED_STRUCT[i].Enable = &speed_para_table[i].Enable;
GUI_SPEED_STRUCT[i]. = &speed_para_table[i].data;
GUI_SPEED_STRUCT[i]. = &speed_para_table[i].data_min;
GUI_SPEED_STRUCT[i]. = &speed_para_table[i].data_max;
GUI_SPEED_STRUCT[i]. = &speed_para_table[i].type;
}
GUI_SPEED_STRUCT[13].DialogBox_Type = MENU_DIALOGBOX;
GUI_SPEED_STRUCT[13]. = 2;
GUI_SPEED_STRUCT[13]. = GUI_Enable_Name;
GUI_SPEED_STRUCT[16].DialogBox_Type = MENU_DIALOGBOX;
GUI_SPEED_STRUCT[16]. = 2;
GUI_SPEED_STRUCT[16]. = GUI_Enable_Name;
}
///////////////////////////////////////////////////////////////////////
//数字对输入框子程序
//由于要求输入数字时,必须还能执行主程序中其它子程序,因此采用返回消息的方式编制
//window_no = 窗口号
//Index = 下拉列表中第几项
//flush=是否刷新过
//string = 输入缓冲区(从该缓冲区中将输入数字转换成数值)
///////////////////////////////////////////////////////////////////////MSG _Cdecl POPUP_MAIN_Number_KeyBoard(int window_no,int Index,BOOL *flush,char *string)
{
int num;
char *p,*q;
GUI_SET_STRUCT_PTR pM;
if (GUI_Key_mark && GUI_Key_Code =='Q')//退出键
{
GUI_Key_mark = FALSE;
return (WM_DESTORY);//返回消毁消息
}
else if (GUI_Key_mark && GUI_Key_Code =='E')//确认键
{
GUI_Key_mark = FALSE;
num = POPUP_String_To_Number(string);
pM = POPUP_GUI_SET_STRUCT_ADDR(window_no) + Index;
if (window_no >= POPUP_STARTUP_WINDOW_NO && window_no <= POPUP_LCD_WINDOW_NO)
{
if (GUI_PassWord_mark)
{
if (POPUP_MAIN_Limit(window_no,Index,num,GUI_Min,GUI_Max))
{
*pM-> = num;
return (WM_VALID);
}
}
else
{
if (num == 1234)
{
GUI_PassWord_mark = TRUE;
return (WM_DESTORY);
}
GUI_Error_Code = PASSWORD_ERROR_CODE;
return (WM_ERROR);
}
}
else if (num >= GUI_Min && num <= GUI_Max)
{
*pM-> = num;
return (WM_VALID);
}
GUI_Error_Code = MIN_MAX_ERROR_CODE;
return (WM_ERROR);
}
else if (GUI_Key_mark && GUI_Key_Code =='C')//清除键
{
GUI_Key_mark = FALSE;
*flush = TRUE;
p = q = string;
while (*p)
//
删除最后一个字符
{
q = p;
p++;
}
*q = '\0';
return (WM_PAINT);
}
else if (GUI_Key_mark && (GUI_Key_Code >= '0' && GUI_Key_Code <= '9'))
{//数字0-数字9键
GUI_Key_mark = FALSE;
p = string;
if (!(*flush))
{
*flush = TRUE;
*p++ = GUI_Key_Code;
*p = '\0';
}
else if (strlen(string) < 7)
{
while (*p)
p++;
*p++ = GUI_Key_Code;
*p = '\0';
}
return (WM_PAINT);
}
return (WM_NO_MSG);
}