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

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

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

void* pXored; // bit-Xored bitmap. PBITMAP pBitmap; // user defined caret bitmap. int nWidth; // original size of caret int nHeight;

int nBytesNr; // number of bitmap bytes. BITMAP caret_bmp; // bitmap of caret. BOOL fBlink; // does blink?

BOOL fShow; // show or hide currently. HWND hOwner; // the window owns the caret. UINT uTime; // the blink time. }CARETINFO;

typedef CARETINFO* PCARETINFO;

(6)消息和消息队列相关的数据结构及函数声明

typedef struct _QMSG {

MSG Msg; struct _QMSG* next; }QMSG;

typedef QMSG* PQMSG;

typedef struct _MSGQUEUE MSGQUEUE; typedef MSGQUEUE* PMSGQUEUE;

typedef BOOL (* IDLEHANDLER) (PMSGQUEUE msg_que); struct _MSGQUEUE {

DWORD dwState; // message queue states

PQMSG pFirstNotifyMsg; // head of the notify message queue PQMSG pLastNotifyMsg; // tail of the notify message queue IDLEHANDLER OnIdle; // Idle handler MSG* msg; /* post message buffer */ int len; /* buffer len */

int readpos, writepos; /* positions for reading and writing */ int FirstTimerSlot; /* the first timer slot to be checked */ DWORD TimerMask; /* timer slots mask */

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

BOOL InitFreeQMSGList (void); void DestroyFreeQMSGList (void);

BOOL InitMsgQueue (PMSGQUEUE pMsgQueue, int iBufferLen); void DestroyMsgQueue (PMSGQUEUE pMsgQueue); BOOL QueueMessage (PMSGQUEUE msg_que, PMSG msg); extern PMSGQUEUE __mg_dsk_msg_queue;

(7)主窗口相关的数据结构

typedef struct _MAINWIN

{ /*

* These fields are similiar with CONTROL struct. */

short DataType; // the data type. short WinType; // the window type.

int left, top; // the position and size of main window. int right, bottom;

int cl, ct; // the position and size of client area. int cr, cb;

DWORD dwStyle; // the styles of main window. DWORD dwExStyle; // the extended styles of main window. int iBkColor; // the background color. HMENU hMenu; // handle of menu. HACCEL hAccel; // handle of accelerator table. HCURSOR hCursor; // handle of cursor. HICON hIcon; // handle of icon.

HMENU hSysMenu; // handle of system menu. PLOGFONT pLogFont; // pointer to logical font. HDC privCDC; // the private client DC.

INVRGN InvRgn; // the invalid region of this main window. PGCRINFO pGCRInfo; // pointer to global clip region info struct. PZORDERNODE pZOrderNode;

PCARETINFO pCaretInfo;// pointer to system caret info struct. DWORD dwAddData; // the additional data. DWORD dwAddData2; // the second addtional data. int (*MainWindowProc)(HWND, int, WPARAM, LPARAM); // the address of main window procedure. char* spCaption; // the caption of main window. int id; // the identifier of main window. SCROLLBARINFO vscroll;// the vertical scroll bar information. SCROLLBARINFO hscroll;// the horizital scroll bar information. struct _MAINWIN* pMainWin;

// the main window that contains this window. // for main window, always be itself. HWND hParent; // the parent of this window.

// for main window, always be HWND_DESKTOP. /*

* Child windows. */

HWND hFirstChild; // the handle of first child window. HWND hActiveChild; // the currently active child window. 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;

// the message queue. GCRINFO GCRInfo;

// the global clip region info struct.

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

typedef struct _MAINWIN* PMAINWIN;

(8)窗口相关的初始化和终止函数声明

11、message.c消息与消息队列相关函数

(1)BOOL InitFreeQMSGList (void)

函数作用:初始化消息列表

(2)void DestroyFreeQMSGList (void)

函数作用:销毁消息列表

(3)inline static PQMSG QMSGAlloc (void)

函数作用:

(4)inline static void FreeQMSG (PQMSG pqmsg)

函数作用:

(5)BOOL InitMsgQueue (PMSGQUEUE pMsgQueue, int iBufferLen)

函数作用:初始化消息队列,包括消息队列的类型、长度、时间槽、时间掩码、并为消息队列分配空间。

(6)void DestroyMsgQueue (PMSGQUEUE pMsgQueue)

函数作用:释放为消息队列分配的存储空间,包括notify类型的消息队列和message消息队列。

(7)PMSGQUEUE GetMsgQueue (HWND hWnd)

函数作用:获得指向消息队列的指针。

(8)BOOL QueueMessage (PMSGQUEUE msg_que, PMSG msg)

函数作用:向消息队列msg_que发送消息msg。

(9)static inline WNDPROC GetWndProc (HWND hWnd)

函数作用:获得窗口处理函数。return ((PMAINWIN)hWnd)->MainWindowProc。

(10)static HWND msgCheckInvalidRegion (PMAINWIN pWin)

函数作用:检查无效区域。函数通过递归调用自身来判断无效区域。

(11)static HWND msgCheckHostedTree (PMAINWIN pHosting)

函数作用:检索主窗口树,返回区域无效的窗口,即返回需要重新绘制的窗口。

(12)BOOL GUIAPI HavePendingMessageEx (HWND hWnd, BOOL bNoDeskTimer)

函数作用:判断是否有挂起的消息,若有,返回TRUE,若无,返回(IdleHandler4StandAlone(NULL))。第二个参数为TRUE时,不考虑QS_DESKTIMER的挂起状态,为FALSE时才将QS_DESKTIMER消息的挂起状态考虑在内。

(13)BOOL GUIAPI HavePendingMessage (HWND hWnd)

函数作用:同(12)。return HavePendingMessageEx (hWnd, FALSE);要将QS_DESKTIMER消

息将的挂起状态考虑在内。

(14)int GUIAPI BroadcastMessage (int iMsg, WPARAM wParam, LPARAM lParam)

参数:int iMsg:消息类型, WPARAM wParam, LPARAM lParam :消息参数。

函数作用:return SendMessage (HWND_DESKTOP, MSG_BROADCASTMSG, 0, (LPARAM)(&msg));

(15)static inline void CheckCapturedMouseMessage (PMSG pMsg)

函数作用:

(16)IS_MSG_WANTED(message)

#define IS_MSG_WANTED(message) \\

( (iMsgFilterMin <= 0 && iMsgFilterMax <= 0) || \\

(iMsgFilterMin > 0 && iMsgFilterMax >= iMsgFilterMin && \\ message >= iMsgFilterMin && message <= iMsgFilterMax) ) 作用:判断消息是否在可识别的消息范围内。

(17)BOOL PeekMessageEx (PMSG pMsg, HWND hWnd, int iMsgFilterMin, int iMsgFilterMax, BOOL bWait, UINT uRemoveMsg)

函数作用:从窗口hWnd的消息队列中获得消息pMsg,并根据uRemoveMsg的值对消息队列进行处理。如果消息队列中没有消息,则:当bWait为TRUE时,进入空闲处理函数获得等待被读取的输入事件,再次从消息队列中读取消息;当bWait为FALSE时,函数执行结束,返回FALSE。

(18)int getIdle()

函数作用:return idle。

(19)BOOL GUIAPI WaitMessage (PMSG pMsg, HWND hWnd)

函数作用:将pMsg指向的内存空间清零。若消息队列中有消息,则返回TRUE,若没有消息,则进入空闲处理函数pMsgQueue->OnIdle (pMsgQueue),继续判断队列中是否有消息。

(20)BOOL GUIAPI PeekPostMessage (PMSG pMsg, HWND hWnd, int iMsgFilterMin, int iMsgFilterMax, UINT uRemoveMsg)

函数作用:获得一个QS_POSTMSG类型的消息并根据uRemoveMsg参数对消息队列进行处理。

(21)int GUIAPI SendMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam)

函数作用:向句柄为hWnd的窗口发送iMsg消息和相关参数并对消息进行处理。 (1)首先获得窗口处理函数:WndProc = GetWndProc(hWnd)

(2)再用该函数对消息进行处理:return (*WndProc)(hWnd, iMsg, wParam, lParam)

(22)int GUIAPI SendNotifyMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam)

函数作用:将iMsg消息加入窗口hWnd的notify消息队列。

(23)int GUIAPI PostMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam)

函数作用:向hWnd的窗口队列发送一个识别码为iMsg,参数为wParam和lParam的消息后立即返回。

(24)int GUIAPI PostQuitMessage (HWND hWnd)

函数作用:向主窗口的消息队列中加入一个退出消息,MSG_QUIT。

(25)int GUIAPI DispatchMessage (PMSG pMsg)

函数作用:分发并处理消息。利用pMsg所在的窗口的窗口处理函数对消息进行处理并返回窗口处理函数的结果。

(26)int GUIAPI ThrowAwayMessages (HWND hWnd)

函数作用:删除消息队列中所有与hWnd相关的消息。

(27)BOOL GUIAPI EmptyMessageQueue (HWND hWnd)

函数作用:清空一个消息队列。

12、ourhdr.h

(1)宏定义最大行数

#define MAXLINE 4096 /* max line length */

(2)声明函数

void err_dump(const char *, ...); /* {App misc_source} */ void err_msg(const char *, ...); void err_quit(const char *, ...); void err_ret(const char *, ...); void err_sys(const char *, ...);

(3)定义监听文件描述符的数据结构

typedef struct listen_fd { int fd; //文件描述符标识符 int hwnd; //句柄 int type; //类型 void* context; // } LISTEN_FD;

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

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