sedit.c

来自「在smartarmm2200上显示波形实现暂停退出的功能」· C语言 代码 · 共 143 行

C
143
字号
/***************************************************************************** 文件名: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 = 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

⌨️ 快捷键说明

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