这是ARM嵌入式系统的实验教程中的MINIGUI的实验源代码!

源代码在线查看: control.c

软件大小: 36142 K
上传用户: LotusAwhaT
关键词: MINIGUI ARM 嵌入式系统 实验教程
下载地址: 免注册下载 普通下载 VIP

相关代码

				/****************************************************************************				* 文件名:Control.C				* 功能:MiniGUI应用例子。				*       设计一个简单的静态文本框(自定义)控件,然后在MiniGUI的窗口中使用此控件。       				* 说明:使用MiniGUI for uC/OS-II,使用ADS 1.2编译器。				****************************************************************************/				/* 包含MiniGUI的配置头文件(编译配置选项) */				#include "MiniGUI_config.h"								/* 包含MiniGUI头文件 */				#include "common.h"				#include "minigui.h"				#include "gdi.h"				#include "window.h"				#include "control.h"								#define MYC_STATIC 	"MYSTATIC1"				#define IDC_STATIC1	1000								HWND hMainWnd;								static int MyControlProc(HWND hwnd, int message, WPARAM wParam, LPARAM lParam)				{				    HDC hdc;								    switch (message) 				    {  case MSG_PAINT:				          hdc = BeginPaint (hwnd);				          TextOut (hdc, 0, 0, "my control");				          EndPaint (hwnd, hdc);				          return(0);				    }								    return(DefaultControlProc (hwnd, message, wParam, lParam));				}												static BOOL RegisterMyControl(void)				{				    WNDCLASS MyClass;								    MyClass.spClassName = MYC_STATIC;				    MyClass.dwStyle     = WS_NONE;				    MyClass.dwExStyle   = WS_EX_NONE;				    MyClass.hCursor     = GetSystemCursor (IDC_BUSY);				    MyClass.iBkColor    = COLOR_lightwhite;				    MyClass.WinProc     = MyControlProc;								    return(RegisterWindowClass (&MyClass));				}								static void UnregisterMyControl(void)				{				    UnregisterWindowClass (MYC_STATIC);				}																static int  WinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)				{   				    switch(message)				    {   case MSG_CREATE:				          CreateWindow(MYC_STATIC, "", WS_VISIBLE | WS_BORDER, IDC_STATIC1, 50, 50, 100, 20, hWnd, 0);				          break;								       case MSG_DESTROY:				          DestroyAllControls(hWnd);				          break;								       case MSG_CLOSE:					  DestroyMainWindow(hWnd);					  PostQuitMessage(hWnd);					  break;								       default:					  return(DefaultMainWinProc(hWnd, message, wParam, lParam));				    }								    return(0);				}												int InitMainWindow(void)				{   MAINWINCREATE  window_info;								    window_info.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;				    window_info.dwExStyle = WS_EX_NONE;				    window_info.spCaption = "MiniGUI";				    window_info.hMenu = 0;				    window_info.hCursor = GetSystemCursor(0);				    window_info.hIcon = 0;				    window_info.MainWindowProc = WinProc;				    window_info.lx = 5;				    window_info.ty = 50;				    window_info.rx = 235;				    window_info.by = 200;				    window_info.iBkColor = COLOR_lightwhite;				    window_info.dwAddData = 0;				    window_info.hHosting = HWND_DESKTOP; 				    				    hMainWnd = CreateMainWindow (&window_info);				    if (hMainWnd == HWND_INVALID) return(0);				      else  return(1);				}												int  MiniGUIMain(int argc, const char *argv[])				{   MSG Msg;								#ifdef _LITE_VERSION				    SetDesktopRect(0,0, 800,600);				#endif								    RegisterMyControl();				    InitMainWindow();				    ShowWindow(hMainWnd, SW_SHOWNORMAL);								    while (GetMessage(&Msg, hMainWnd)) 				    {   TranslateMessage(&Msg);				        DispatchMessage(&Msg);				    }				    				    MainWindowThreadCleanup (hMainWnd);				    UnregisterMyControl();				    return(0);				}								#ifndef _LITE_VERSION					#include "dti.c"				#endif							

相关资源