?? sedit.c
字號(hào):
/***************************************************************************** 文件名:Sedit.C* 功能:MiniGUI應(yīng)用例子。* 使用MiniGUI創(chuàng)建主窗口,在窗口過程函數(shù)中處理字符消息,實(shí)現(xiàn)一個(gè)簡* 易編輯器的功能。 * 說明:使用MiniGUI for uC/OS-II,使用ADS 1.2編譯器。****************************************************************************//* 包含MiniGUI的配置頭文件(編譯配置選項(xiàng)) */#include "MiniGUI_config.h"/* 包含MiniGUI頭文件 */#include "common.h"#include "minigui.h"#include "gdi.h"#include "window.h"#include "control.h"HWND hMainWnd;static int WinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){ HDC hdc; static char str_buf[1000]; static int no; static int y; static int char_w, char_h; switch(message) { case MSG_CREATE: CreateCaret(hWnd, NULL, 2, GetSysCharHeight()); // create the caret is 2(width) SetCaretBlinkTime(hWnd, 500); char_w = GetSysCharWidth(); char_h = GetSysCharHeight(); sprintf(str_buf, ""); no = 0; y = 0; break; case MSG_PAINT: hdc = BeginPaint(hWnd); TextOut(hdc, 0, y, str_buf); EndPaint(hWnd, hdc); SetCaretPos(hWnd, 0,0); break; case MSG_SETFOCUS: ShowCaret(hWnd); break; case MSG_KILLFOCUS: HideCaret(hWnd); break; case MSG_CLOSE: DestroyCaret(hWnd); // destroy the caret DestroyMainWindow(hWnd); PostQuitMessage(hWnd); break; case MSG_CHAR: if(wParam==127) { if(no>0) { no--; str_buf[no] = ' '; } } else { str_buf[no++] = wParam; str_buf[no] = '\0'; } if( ((no%30) == 0) || (wParam == 0x0D ) ) { if(no>0) { y = y + char_h; no = 0; str_buf[0] = '\0'; } } hdc = BeginPaint(hWnd); TextOut(hdc, 0, y, str_buf); EndPaint(hWnd, hdc); SetCaretPos(hWnd, no * char_w, y); 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_IMECOMPOSE; window_info.spCaption = "Please input the key"; window_info.hMenu = 0; window_info.hCursor = GetSystemCursor(0); window_info.hIcon = 0; window_info.MainWindowProc = WinProc; window_info.lx = 0; window_info.ty = 50; window_info.rx = 239; window_info.by = 250; 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 InitMainWindow(); ShowWindow(hMainWnd, SW_SHOWNORMAL); while (GetMessage(&Msg, hMainWnd)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } MainWindowThreadCleanup (hMainWnd); return(0);}#ifndef _LITE_VERSION #include "dti.c"#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -