目录一、minigui运行模式....................................................................................................11、线程模式:MiniGui-Threads......................................................................................12、进程模式:MiniGui-Processes...................................................................................13、独立应用模式:MiniGui-Standalone........................................................................2二、数据结构................................................................................................................21、CreateMainWindow函数参数:PMAINWINCREATEpCreateInfo..........................22、MAINWIN结构体:主窗口的详细信息由该结构体给出........................................23、MSGQUEUE消息队列................................................................................................4三、CreateMainWindow函数流程.................................................................................41、判断传入的参数pCreateInfo是否为空....................................................................42、为PMAINWIN类型的pWin分配内存空间,并判断pWin是否为空..................43、是否定义_LITE_VERSION:........................................................................................44、设置pWin的成员:..................................................................................................45、SendMessage((HWND)pWin,MSG_NCCREATE,0,(LPARAM)pCreateInfo)................66、SendMessage((HWND)pWin,MSG_SIZECHANGING,(WPARAM)&pCreateInfo-lx,(LPARAM)&pWin-left);........................................................................................................77、SendMessage((HWND)pWin,MSG_CHANGESIZE,(WPARAM)&pWin-left,0).........78、SendMessage(HWND_DESKTOP,MSG_ADDNEWMAINWIN,(WPARAM)pWin,(LPARAM)pWin-pZOrderNode);.............................................................................................79、SendMessage((HWND)pWin,MSG_CREATE,0,(LPARAM)pCreateInfo).....................8四、ShowWindow函数流程..........................................................................................81、MG_CHECK_RET(MG_IS_NORMAL_WINDOW(hWnd),FALSE)..................................82、根据窗口类型和窗口的显示类型对窗口的显示状态进行调整.............................8如果hWnd指示的窗口是主窗口:.......................................................................9如果hWnd指示的窗口是控件窗口:...................................................................93、根据iCmdShow等信息确定当前窗口是否失去输入焦点...................................104、向消息队列发送消息MSG_SHOWWINDOW根据iCmdShow指示当前窗口的显示状态.....................................................................................................................................10一、minigui运行模式1、线程模式:MiniGui-Threads定义:_MGRM_THREADS运行在MiniGui-Threads上的程序可以在不同的线程中建立多个窗口,但所有的窗口在一个进程或地址空间中运行,传统意义上的嵌入式操作系统。2、进程模式:MiniGui-Processes定义:_MGRM_Processes或者定义_LITE_VERSIONMiniGui-Processes上每个程序是单独的进程,每个进程也可以建立多个窗口,并且实现了多进程窗口系统。适用于具有完整UNIX特性的嵌入式式系统。3、独立应用模式:MiniGui-Standalone定义:_MGRM_STANDALONE或者定义_LITE_VERSION和_STAND_ALONE通过独立任务的方式运行,既不需要多进程支持也不需要多线程支持。二、创建主窗口CreateMainWindow1、数据结构1、CreateMainWindow函数参数:PMAINWINCREATEpCreateInfo结构体MAINWINCREATE定义了被创建的窗口的位置、标题、类型等基本参数。实际上包含了创建窗口的UI风格和窗口处理函数两方面的内容。PMAINWINCREATE为指向该结构体的指针。typedefstruct_MAINWINCREATE{DWORDdwStyle;//主窗口的类型DWORDdwExStyle;//主窗口的扩展类型constchar*spCaption;//主窗口的标题HMENUhMenu;//主窗口菜单句柄HCURSORhCursor;//主窗口光标句柄HICONhIcon;//主窗口图标句柄HWNDhHosting;//主窗口的托管窗口Thehostingmainwindowint(*MainWindowProc)(HWND,int,WPARAM,LPARAM);//窗口回调函数intlx,ty,rx,by;//主窗口在屏幕坐标中的位置intiBkColor;//主窗口颜色的像素值DWORDdwAddData;//私有数据ThefirstprivatedataassociatedwiththemainwindowDWORDdwReserved;//没有用到}MAINWINCREATE;typedefMAINWINCREATE*PMAINWINCREATE;2、MAINWIN结构体:主窗口的详细信息由该结构体给出typedefstruct_MAINWIN{/**ThesefieldsaresimiliarwithCONTROLstruct.*/shortDataType;//thedatatype.shortWinType;//thewindowtype.intleft,top;//thepositionandsizeofmainwindow.intright,bottom;intcl,ct;//thepositionandsizeofclientarea.intcr,cb;DWORDdwStyle;//thestylesofmainwindow.DWORDdwExStyle;//theextendedstylesofmainwindow.intiBkColor;//thebackgroundcolor.HMENUhMenu;//handleofmenu.HACCELhAccel;//handleofacceleratortable.HCURSORhCursor;//handleofcursor.HICONhIcon;//handleoficon.HMENUhSysMenu;//handleofsystemmenu.PLOGFONTpLogFont;//pointertologicalfont.HDCprivCDC;//theprivateclientDC.INVRGNInvRgn;//theinvalidregionofthismainwindow.PGCRINFOpGCRInfo;//pointertoglobalclipregioninfostruct.PZORDERNODEpZOrderNode;PCARETINFOpCaretInfo;//pointertosystemcaretinfostruct.DWORDdwAddData;//theadditionaldata.DWORDdwAddData2;//thesecondaddtionaldata.int(*MainWindowProc)(HWND,int,WPARAM,LPARAM);//theaddressofmainwindowprocedure.char*spCaption;//thecaptionofmainwindow.intid;//theidentifierofmainwindow.SCROLLBARINFOvscroll;//theverticalscrollbarinformation.SCROLLBARINFOhscroll;//thehorizitalscrollbarinformation.struct_MAINWIN*pMainWin;//themainwindowthatcontainsthiswindow.//formainwindow,alwaysbeitself.HWNDhParent;//theparentofthiswindow.//formainwindow,alwaysbeHWND_DESKTOP./**Childwindows.*/HWNDhFirstChild;//thehandleoffirstchildwindow.HWNDhActiveChild;//thecurrentlyactivechildwindow.HWNDhOldUnderPointer;//theoldchildwindowunderpointe