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

minigui代码分析

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

目录

一、minigui运行模式 .................................................................................................... 1

1、线程模式:MiniGui-Threads ...................................................................................... 1 2、进程模式:MiniGui-Processes ................................................................................... 1 3、独立应用模式:MiniGui-Standalone ........................................................................ 2 二、数据结构 ................................................................................................................ 2

1、CreateMainWindow函数参数:PMAINWINCREATE pCreateInfo .......................... 2 2、MAINWIN结构体:主窗口的详细信息由该结构体给出........................................ 2 3、MSGQUEUE消息队列 ................................................................................................ 4 三、CreateMainWindow函数流程 ................................................................................. 4

1、判断传入的参数pCreateInfo是否为空 .................................................................... 4 2、为PMAINWIN类型的 pWin分配内存空间,并判断pWin是否为空 .................. 4 3、是否定义_LITE_VERSION: ........................................................................................ 4 4、设置pWin的成员: .................................................................................................. 4 5、SendMessage ((HWND)pWin, MSG_NCCREATE, 0, (LPARAM)pCreateInfo) ................ 6 6、SendMessage ((HWND)pWin, MSG_SIZECHANGING,(WPARAM)&pCreateInfo->lx, (LPARAM)&pWin->left); ........................................................................................................ 7

7、SendMessage ((HWND)pWin, MSG_CHANGESIZE, (WPARAM)&pWin->left, 0) ......... 7 8、SendMessage (HWND_DESKTOP, MSG_ADDNEWMAINWIN, (WPARAM) pWin, (LPARAM) pWin->pZOrderNode); ............................................................................................. 7

9、SendMessage ((HWND)pWin, MSG_CREATE, 0, (LPARAM)pCreateInfo)..................... 8 四、ShowWindow函数流程 .......................................................................................... 8

1、MG_CHECK_RET (MG_IS_NORMAL_WINDOW(hWnd), FALSE) .................................. 8 2、根据窗口类型和窗口的显示类型对窗口的显示状态进行调整 ............................. 8

如果hWnd指示的窗口是主窗口: ....................................................................... 9 如果hWnd指示的窗口是控件窗口: ................................................................... 9 3、根据iCmdShow等信息确定当前窗口是否失去输入焦点 ................................... 10 4、向消息队列发送消息MSG_SHOWWINDOW根据iCmdShow指示当前窗口的显示状态..................................................................................................................................... 10

一、minigui运行模式

1、线程模式:MiniGui-Threads

定义:_MGRM_THREADS

运行在MiniGui-Threads上的程序可以在不同的线程中建立多个窗口,但所有的窗口在一个进程或地址空间中运行,传统意义上的嵌入式操作系统。

2、进程模式:MiniGui-Processes

定义:_MGRM_Processes或者定义_LITE_VERSION

MiniGui-Processes上每个程序是单独的进程,每个进程也可以建立多个窗口,并且实现了多进程窗口系统。适用于具有完整UNIX特性的嵌入式式系统。

3、独立应用模式:MiniGui-Standalone

定义:_MGRM_STANDALONE 或者定义_LITE_VERSION和_STAND_ALONE

通过独立任务的方式运行,既不需要多进程支持也不需要多线程支持。

二、创建主窗口CreateMainWindow

1、数据结构

1、CreateMainWindow函数参数:PMAINWINCREATE pCreateInfo

结构体MAINWINCREATE 定义了被创建的窗口的位置、标题、类型等基本参数。实际上包含了创建窗口的UI风格和窗口处理函数两方面的内容。

PMAINWINCREATE为指向该结构体的指针。 typedef struct _MAINWINCREATE { DWORD dwStyle; //主窗口的类型 DWORD dwExStyle; //主窗口的扩展类型 const char* spCaption; //主窗口的标题 HMENU hMenu; //主窗口菜单句柄 HCURSOR hCursor; //主窗口光标句柄 HICON hIcon; //主窗口图标句柄

HWND hHosting; //主窗口的托管窗口The hosting main window

int (*MainWindowProc)(HWND, int, WPARAM, LPARAM); // 窗口回调函数 int lx, ty, rx, by; //主窗口在屏幕坐标中的位置 int iBkColor; //主窗口颜色的像素值

DWORD dwAddData; //私有数据The first private data associated with the main window

DWORD dwReserved; //没有用到 }MAINWINCREATE;

typedef MAINWINCREATE* PMAINWINCREATE;

2、MAINWIN结构体:主窗口的详细信息由该结构体给出 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;

3、MSGQUEUE消息队列

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. */ };

2、CreateMainWindow函数流程

1、判断传入的参数pCreateInfo是否为空

Case NULL:若参数为空,返回HWND_INVALID Case NOT NULL:若参数不为空,继续执行2

2、为PMAINWIN类型的 pWin分配内存空间,并判断pWin是否为空

Case NULL:分配空间失败,返回HWND_INVALID

Case NOT NULL:分配空间成功,继续执行3

3、是否定义_LITE_VERSION:

3.a没有定义_LITE_VERSION,代表minigui的运行模式为MiniGui-Threads 设置pWin的成员pWin->pMessages和pWin->pHosting

3.b定义了_LITE_VERSION,代表minigui的运行模式为非MiniGui-Threads 设置pWin的成员pWin->pMessages和pWin->pHosting

4、设置pWin的成员:

pWin->pMainWin = pWin; pWin->hParent = 0; pWin->pFirstHosted = NULL; pWin->pNextHosted = NULL; pWin->DataType = TYPE_HWND; pWin->WinType = TYPE_MAINWIN;

#ifndef _LITE_VERSION

pWin->th = pthread_self();

#endif

pWin->hFirstChild = 0; pWin->hActiveChild = 0; pWin->hOldUnderPointer = 0; pWin->hPrimitive = 0;

pWin->NotifProc = NULL;

pWin->dwStyle = pCreateInfo->dwStyle; pWin->dwExStyle = pCreateInfo->dwExStyle;

pWin->hMenu = pCreateInfo->hMenu; pWin->hCursor = pCreateInfo->hCursor; pWin->hIcon = pCreateInfo->hIcon;

if ((pWin->dwStyle & WS_CAPTION) && (pWin->dwStyle & WS_SYSMENU)) pWin->hSysMenu= CreateSystemMenu ((HWND)pWin, pWin->dwStyle); else

pWin->hSysMenu = 0;

pWin->pLogFont = GetSystemFont (SYSLOGFONT_WCHAR_DEF);

pWin->spCaption = FixStrAlloc (strlen (pCreateInfo->spCaption)); if (pCreateInfo->spCaption [0])

strcpy (pWin->spCaption, pCreateInfo->spCaption);

pWin->MainWindowProc = pCreateInfo->MainWindowProc; pWin->iBkColor = pCreateInfo->iBkColor;

pWin->pCaretInfo = NULL;

pWin->dwAddData = pCreateInfo->dwAddData; pWin->dwAddData2 = 0;

#if !defined (_LITE_VERSION) || defined (_STAND_ALONE) if ( !( pWin->pZOrderNode = malloc (sizeof(ZORDERNODE))) ) goto err; #endif

/* Scroll bar */

if (pWin->dwStyle & WS_VSCROLL) { pWin->vscroll.minPos = 0; pWin->vscroll.maxPos = 100; pWin->vscroll.curPos = 0; pWin->vscroll.pageStep = 0;

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

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