?? control.c
字號:
/***************************************************************************** 文件名: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 1000HWND 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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -