77范文网 - 专业文章范例文档资料分享平台

MINIGUI输入模块代码文件分析(6)

来源:网络收集 时间:2019-04-09 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

(3)消息队列数据结构

struct _MSGQUEUE {

DWORD dwState; // message queue states,消息队列的状态,包含的消息类型 PQMSG pFirstNotifyMsg; // notify消息队列的第一个消息 PQMSG pLastNotifyMsg; // notify消息队列的最后一个消息 IDLEHANDLER OnIdle; // 空闲处理函数

MSG* msg; // post 类型的消息的缓存地址 int len; //缓存长度 int readpos, writepos; //读写位置

int FirstTimerSlot; /* the first timer slot to be checked */ DWORD TimerMask; /* timer slots mask */

int loop_depth; /* message loop depth, for dialog boxes. */ };

typedef struct _MSGQUEUE MSGQUEUE; typedef MSGQUEUE* PMSGQUEUE;

typedef BOOL (* IDLEHANDLER) (PMSGQUEUE msg_que);

6、定义主窗口数据结构

(1)创建主窗口时需要的数据结构

typedef struct _MAINWINCREATE

{

DWORD dwStyle; //主窗口的类型 DWORD dwExStyle; //主窗口的扩展类型 const char* spCaption; //主窗口的标题 HMENU hMenu;//主窗口的菜单句柄 HCURSOR hCursor;//主窗口的光标句柄 HICON hIcon; //主窗口的图标句柄 HWND hHosting;//托管窗口

int (*MainWindowProc)(HWND, int, WPARAM, LPARAM);//窗口处理函数 int lx, ty, rx, by;//窗口位置大小 int iBkColor;//窗口颜色

DWORD dwAddData;//窗口附加数据 DWORD dwReserved;//保留项 }MAINWINCREATE;

typedef MAINWINCREATE* PMAINWINCREATE;

(2)主窗口数据结构:

typedef struct _MAINWIN { /*

* These fields are similiar with CONTROL struct. */

short DataType; // 数据类型 short WinType; // 窗口类型 int left, top; // 窗口位置大小 int right, bottom;

int cl, ct; // 客户区域的位置大小 int cr, cb;

DWORD dwStyle; // 主窗口风格 DWORD dwExStyle; //主窗口扩展风格 int iBkColor; // 背景色 HMENU hMenu; //菜单句柄 HACCEL hAccel; // 加速表句柄 HCURSOR hCursor; //光标句柄 HICON hIcon; // 图标句柄 HMENU hSysMenu; // 系统菜单句柄 PLOGFONT pLogFont; // 指向逻辑字体的指针 HDC privCDC; // the private client DC. INVRGN InvRgn; // 主窗口无效客户区域

PGCRINFO pGCRInfo; // pointer to global clip region info struct. PZORDERNODE pZOrderNode;

PCARETINFO pCaretInfo;// pointer to system caret info struct. DWORD dwAddData; // 附加数据 DWORD dwAddData2; // 附加数据

int (*MainWindowProc)(HWND, int, WPARAM, LPARAM);// 窗口处理函数 char* spCaption; //主窗口标题 int id; // 窗口标识符

SCROLLBARINFO vscroll;// 垂直滚动条信息 SCROLLBARINFO hscroll;// 水平滚动条信息

struct _MAINWIN* pMainWin; //包含该窗口的主窗口,经常是自身 HWND hParent; //父窗口,主窗口的父窗口一般是HWND_DESKTOP /*

* Child windows. */

HWND hFirstChild; // 第一个子窗口句柄 HWND hActiveChild; // 当前处于活跃状态的子窗口

HWND hOldUnderPointer; // the old child window under pointer. HWND hPrimitive; // the premitive child of mouse event. NOTIFPROC NotifProc; // the notification callback procedure. /*

* window element data. */

struct _wnd_element_data* wed; /*

* Main Window hosting.

* The following members are only implemented for main window.

*/

struct _MAINWIN* pHosting; // the hosting main window. struct _MAINWIN* pFirstHosted;// the first hosted main window. struct _MAINWIN* pNextHosted;// the next hosted main window. PMSGQUEUE pMessages; // 消息队列 GCRINFO GCRInfo;

// the global clip region info struct.

// put here to avoid invoking malloc function. } MAINWIN; struct _MAINWIN;

typedef struct _MAINWIN* PMAINWIN;

三、重要函数

1、底层事件初始化InitLWEvent():

BOOL InitLWEvent (void) {

GetDblclickTime (); //获得鼠标双击时间间隔 GetTimeout (); //获得超时时间 if (InitIAL ()) //初始化输入抽象层 return FALSE;

ResetMouseEvent(); //重置鼠标事件 ResetKeyEvent(); //重置键盘事件 return TRUE;

}

2、初始化输入抽象层InitIAL ():

int InitIAL (void) {

int i;

char engine [LEN_ENGINE_NAME + 1]; //输入引擎名称 char mdev [MAX_PATH + 1]; //路径 char mtype[LEN_MTYPE_NAME + 1]; //类型

if (NR_INPUTS == 0) //如果没有输入引擎,返回错误信息 return ERR_NO_ENGINE;

//将system的ial_engine段的值复制给engine指向的地址

if (GetMgEtcValue (\, \, engine, LEN_ENGINE_NAME) < 0) return ERR_CONFIG_FILE;

if (GetMgEtcValue (\, \, mdev, MAX_PATH) < 0) return ERR_CONFIG_FILE;

if (GetMgEtcValue (\, \, mtype, LEN_MTYPE_NAME) < 0) return ERR_CONFIG_FILE;

//找到与engine相等的字符串,由此来确定当前的输入引擎__mg_cur_input

for (i = 0; i < NR_INPUTS; i++) {

if (strncmp (engine, inputs[i].id, LEN_ENGINE_NAME) == 0) { __mg_cur_input = inputs + i; break; } }

//如果当前输入引擎为空 if (__mg_cur_input == NULL) {

fprintf (stderr, \, engine); if (NR_INPUTS) { //输入引擎数组不为空

__mg_cur_input = inputs;//当前输入引擎为输入引擎数组的第一个 fprintf (stderr, \, __mg_cur_input->id); } else

return ERR_NO_MATCH; }

//将mdev存储的路径字符串复制给__mg_cur_input->mdev strcpy (__mg_cur_input->mdev, mdev);

//根据输入引擎选择对应的输入初始化函数对输入进行初始化 if (!IAL_InitInput (__mg_cur_input, mdev, mtype)) { fprintf (stderr, \); return ERR_INPUT_ENGINE; } return 0; }

3、standalone模式下的空闲操作函数:IdleHandler4StandAlone

函数作用:将输入事件转换成对应的消息并放入消息队列中

BOOL IdleHandler4StandAlone (PMSGQUEUE msg_queue) {

int i, n; int rset, wset, eset; int * wsetptr = NULL; int * esetptr = NULL;

if (old_timer_counter != __mg_timer_counter) { old_timer_counter = __mg_timer_counter; SetDesktopTimerFlag (); }

rset = mg_rfdset; /* rset gets modified each time around */ if (mg_wfdset) { wset = *mg_wfdset; wsetptr = &wset;

}

if (mg_efdset) { eset = *mg_efdset; esetptr = &eset; }

n = IAL_WaitEvent (IAL_MOUSEEVENT | IAL_KEYEVENT, mg_maxfd, &rset, wsetptr, esetptr, NULL);

if (msg_queue == NULL) msg_queue = __mg_dsk_msg_queue;

if (n < 0) {//表示等待事件函数IAL_WaitEvent中出错

/* It is time to check event again. */

if (errno == EINTR) {//出错类型为中断,则解析消息队列 //if (msg_queue)

ParseEvent (msg_queue, 0); }

return FALSE; } /*

else if (msg_queue == NULL) return (n > 0); */

/* handle intput event (mouse/touch-screen or keyboard) */ //等待事件为鼠标事件,解析消息队列

if (n & IAL_MOUSEEVENT) ParseEvent (msg_queue, IAL_MOUSEEVENT); //等待事件为键盘事件,解析消息队列

if (n & IAL_KEYEVENT) ParseEvent (msg_queue, IAL_KEYEVENT); //等待事件为超时事件,解析消息队列

if (n == 0) ParseEvent (msg_queue, 0);

/* go through registered listen fds */

for (i = 0; i < MAX_NR_LISTEN_FD; i++) { MSG Msg;

Msg.message = MSG_FDEVENT;

if (mg_listen_fds [i].fd) { fd_set* temp = NULL;

int type = mg_listen_fds [i].type;

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库MINIGUI输入模块代码文件分析(6)在线全文阅读。

MINIGUI输入模块代码文件分析(6).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/583185.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: