⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sedit.c

📁 MiniGUI for uCOS 移植实验全部源码
💻 C
字号:
/***************************************************************************** 文件名:Sedit.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"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 = 0;    window_info.hIcon = 0;    window_info.MainWindowProc = WinProc;    window_info.lx = 50;    window_info.ty = 20;    window_info.rx = 290;    window_info.by = 230;    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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -