STemWin学习:关于窗口消息的基础知识

STemWin学习:关于窗口消息的基础知识刚开始接触emWin,记录一下我自己感悟的心得。首先从GUIBuilder小工具创建的窗口文件讲解。//USERSTART(Optionallyinsertadditionalstaticdata)#defineBUTTON_SIZE_X20#defineBUTTON_SIZE_Y20#defineBUTTON_START_X55#define…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

刚开始接触emWin,记录一下我自己感悟的心得。

首先从GUIBuilder小工具创建的窗口文件讲解。

// USER START (Optionally insert additional static data)
#define BUTTON_SIZE_X   20
#define BUTTON_SIZE_Y   20
#define BUTTON_START_X  55
#define BUTTON_START_Y  90
#define BUTTON_GAP_XY    5
// USER END
/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 40, 125, 260,105, 0, 0x64, 0 },//相对于父窗口的Client区的位置
{ BUTTON_CreateIndirect, "q", ID_BUTTON_0, 5, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },//注意!控件位置是相对于窗口的
{ BUTTON_CreateIndirect, "w", ID_BUTTON_1, 30, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "e", ID_BUTTON_2, 55, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "r", ID_BUTTON_3, 80, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "t", ID_BUTTON_4, 105, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "y", ID_BUTTON_5, 130, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "u", ID_BUTTON_6, 155, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "i", ID_BUTTON_7, 180, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "o", ID_BUTTON_8, 205, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "p", ID_BUTTON_9, 230, 5, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "a", ID_BUTTON_10,5, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "s", ID_BUTTON_11,30, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "d", ID_BUTTON_12,55, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "f", ID_BUTTON_13,80, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "g", ID_BUTTON_14,105, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "h", ID_BUTTON_15,130, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "j", ID_BUTTON_16,155, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "k", ID_BUTTON_17, 180, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "l", ID_BUTTON_18, 205, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "_", ID_BUTTON_19, 230, 30, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "z", ID_BUTTON_20, 5, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "x", ID_BUTTON_21, 30, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "c", ID_BUTTON_22, 55, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "v", ID_BUTTON_23, 80, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "b", ID_BUTTON_24, 105, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "n", ID_BUTTON_25, 130, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "m", ID_BUTTON_26, 155, 55, BUTTON_SIZE_X, BUTTON_SIZE_Y, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Enter", ID_BUTTON_27, 200, 55, 50, 45, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "ESC", ID_BUTTON_28, 5, 80, 40, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Caps", ID_BUTTON_29, 50, 80, 55, 20, 0x0, 0 },
{ BUTTON_CreateIndirect, "EN", ID_BUTTON_30, 110, 80, 30, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Backsp", ID_BUTTON_31, 145, 80, 50, 20, 0, 0x0, 0 },
};
// USER START (Optionally insert additional widgets)
// USER END
/*********************************************************************
*
*       Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
static const char keyCAP[] = {
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P',
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '_',
'Z', 'X', 'C', 'V', 'B', 'N', 'M', 0};
static const char keyLOW[] = {
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', '_',
'z', 'x', 'c', 'v', 'b', 'n', 'm', 0};
static const char key123[] = {
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'!', '@', '%', '*', '(', ')', '_', '-', '+', '=',
'/', ':', ';', '"', ',', '.', '?', 0};
// USER END
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;  //目标窗口
int     NCode;
int     Id,uib_num;
// USER START (Optionally insert additional variables)
char charBUFF[20];
static unsigned char capsKEY = 0, inputTYPE = 0;
WM_MESSAGE Message;
// USER END
switch (pMsg->MsgId) {  //消息类型 MsgId 窗口发送的消息,窗口发生变化(内容,数值)时会发送
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
WINDOW_SetBkColor(hItem, (0x00C0C0C0));
for(uib_num=ID_BUTTON_0;uib_num <= ID_BUTTON_31;uib_num++)
{
hItem = WM_GetDialogItem(pMsg->hWin, uib_num);
BUTTON_SetFont(hItem, GUI_FONT_16_1);
BUTTON_SetFocussable(hItem, 0);
}
break;
case WM_NOTIFY_PARENT:
Id    = WM_GetId(pMsg->hWinSrc);  //源窗口 hWinSrc 窗口中发送消息的控件(控件也是一个小窗口)
NCode = pMsg->Data.v; //数据值 Data.v (控件发送的消息,比如控件被点击,内容改变)
switch(Id) {
case ID_BUTTON_0:
case ID_BUTTON_1:
case ID_BUTTON_2:
case ID_BUTTON_3:
case ID_BUTTON_4:
case ID_BUTTON_5:
case ID_BUTTON_6:
case ID_BUTTON_7:
case ID_BUTTON_8:
case ID_BUTTON_9:
case ID_BUTTON_10:
case ID_BUTTON_11:
case ID_BUTTON_12:
case ID_BUTTON_13:
case ID_BUTTON_14:
case ID_BUTTON_15:
case ID_BUTTON_16:
case ID_BUTTON_17:
case ID_BUTTON_18:
case ID_BUTTON_19:
case ID_BUTTON_20:
case ID_BUTTON_21:
case ID_BUTTON_22:
case ID_BUTTON_23:
case ID_BUTTON_24:
case ID_BUTTON_25:
case ID_BUTTON_26:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
BUTTON_GetText(pMsg->hWinSrc, &charBUFF[0], sizeof(charBUFF));
GUI_StoreKeyMsg(charBUFF[0], 1);	//store key to EMWIN
GUI_StoreKeyMsg(charBUFF[0], 0);
// USER END
break;
}
break;
case ID_BUTTON_27: // Notifications sent by 'Enter'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
GUI_StoreKeyMsg(GUI_KEY_ENTER, 1);
GUI_StoreKeyMsg(GUI_KEY_ENTER, 0);
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
case ID_BUTTON_28: // Notifications sent by 'ESC'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
WM_HideWindow(pMsg->hWin);
inputTYPE = (inputTYPE <= 0) ? 1 : (inputTYPE-1);
Message.hWinSrc = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_30);
Message.MsgId = WM_NOTIFY_PARENT;
Message.Data.v = WM_NOTIFICATION_RELEASED;
WM_SendMessage(pMsg->hWin, &Message);
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_29: // Notifications sent by 'Caps'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
capsKEY = !capsKEY;
if(inputTYPE==1) break;
if(capsKEY) BUTTON_SetTextColor(pMsg->hWinSrc, BUTTON_CI_UNPRESSED, GUI_RED);
else BUTTON_SetTextColor(pMsg->hWinSrc, BUTTON_CI_UNPRESSED, GUI_BLACK);
for(Id=ID_BUTTON_0; Id<=ID_BUTTON_26; Id++)	//change to English keyboard
{
charBUFF[0] = capsKEY ? keyCAP[Id-ID_BUTTON_0] : keyLOW[Id-ID_BUTTON_0]; charBUFF[1] = 0;
BUTTON_SetText(WM_GetDialogItem(pMsg->hWin, Id), &charBUFF[0]);
BUTTON_SetTextColor(WM_GetDialogItem(pMsg->hWin, Id), BUTTON_CI_UNPRESSED, (!capsKEY&&(inputTYPE==2)) ? GUI_BLUE : GUI_BLACK);
}
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_30: // Notifications sent by 'En'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
inputTYPE = !inputTYPE;
if(!capsKEY){
if(inputTYPE)
for(uib_num=ID_BUTTON_0; uib_num<=ID_BUTTON_26; uib_num++)
{
BUTTON_SetTextColor(WM_GetDialogItem(pMsg->hWin, uib_num), BUTTON_CI_UNPRESSED, GUI_BLACK);
BUTTON_SetText(pMsg->hWinSrc, "123");
charBUFF[0] = key123[uib_num-ID_BUTTON_0]; charBUFF[1] = 0;
BUTTON_SetText(WM_GetDialogItem(pMsg->hWin, uib_num), &charBUFF[0]);
}
else
for(uib_num=ID_BUTTON_0; uib_num<=ID_BUTTON_26; uib_num++)
{
BUTTON_SetTextColor(WM_GetDialogItem(pMsg->hWin, uib_num), BUTTON_CI_UNPRESSED, GUI_BLACK);
BUTTON_SetText(pMsg->hWinSrc, "EN");
charBUFF[0] = keyLOW[uib_num-ID_BUTTON_0]; charBUFF[1] = 0;
BUTTON_SetText(WM_GetDialogItem(pMsg->hWin, uib_num), &charBUFF[0]);
}
}
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_31:   // Notifications sent by 'Backspace'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
GUI_StoreKeyMsg(GUI_KEY_BACKSPACE, 1);
GUI_StoreKeyMsg(GUI_KEY_BACKSPACE, 0);
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER END
}
break;
// USER START (Optionally insert additional message handling)
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateInput
*/
WM_HWIN CreateInput(void);
WM_HWIN CreateInput(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);//创建非阻塞对话框,父窗口的句柄为WM_HBKWIN
return hWin;
}

Jetbrains全家桶1年46,售后保障稳定

  1. 这实际上是我参照别人的按键程序,自己改写后的软键盘,所需要记录的都在代码中有注释,下面张贴一下效果图:STemWin学习:关于窗口消息的基础知识
  2. 刚开始学习还有很多不会的,后续会继续记录自己的学习过程。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/223056.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • GOF23-创建型:简单工厂模式

    GOF23-创建型:简单工厂模式

  • 手机上好用的java编译器_手机上好用的java编译器

    手机上好用的java编译器_手机上好用的java编译器手机上好用的java编译器安卓版是一款专为java开发人员服务的编辑客户端应用,利用手机上好用的java编译器手机安卓版实时进行相关编辑还能进行简单的编译,运行单个小程序等,提供您的效率。功能介绍手机上好用的java编译器安卓版是一款将openjdk中关于编译java工程的代码移植到了安卓平台。手机上好用的java编译器手机安卓版支持添加jar格式的lib文件,并且将编译后的程序dex化,以便在安…

  • Open-E DSS V7 应用系列之七 卷组和卷的管理

    Open-E DSS V7 应用系列之七 卷组和卷的管理

  • xshell连接虚拟机步骤_安装虚拟机后如何使用

    xshell连接虚拟机步骤_安装虚拟机后如何使用Xshell连接虚拟机1、打开虚拟机终端,输入下面命令,找到ens33对应的IP地址,如图ifconfig2、打开Xshell,打开文件–>新建3、填写名称,主机这里填入刚才的IP,点击连接4、输入登录的用户名,点击确定5、输入密码,点击确定6、连接成功,可以开始使用…

  • java实现简单的图书管理系统「建议收藏」

    java实现简单的图书管理系统「建议收藏」一、项目分布Book类:定义了书的一些属性(书名,作者,价格,分类,状态)并且写了属性的get、set方法Library类:写了登录函数(1、普通用户,2、管理员,3、退出系统),Person类:定义的人的属性(姓名,性别,年龄)并且写了属性的get、set方法,定义了一些书。operate接口:操作的接口,操作方法:查询/查阅,删除/借阅,增加/还书,显示书籍列表Root类:继承…

  • 软件类网站源码(诱导类源码)

    /**====================================================================*LicensedtotheApacheSoftwareFoundation(ASF)underone*ormorecontributorlicenseagreements.SeetheNOTICEfile

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号