首页 > 期刊发表知识库 > 文本编辑器设计

文本编辑器设计

发布时间:

文本编辑器设计

直接用MFC自动生成实现吧,不过要改一个基类,是改成CEDIT

行文本编辑器设计

用VC吧,里面有模版

不好意思 没看清楚 你已经调用字体对话框了。。。。

wqwerxser

设计一个文本编辑器

如果是基于字符界面的话,给你个思路1、整个程序的逻辑是一个循环while(0){捕获键盘输入根据输入确定执行的功能:1、功能操作2、编辑输入或修改操作刷新显示缓冲区的内容}2、键盘输入包括字符、功能键(Fx、del、bk等等)、方向键3、缓冲区是一个动态链表,链表的每个元素是一个字符串,表示是屏幕上一行的内容,可以根据要求限制长度或者调整显示方式

直接用MFC自动生成实现吧,不过要改一个基类,是改成CEDIT

文本编辑器课程设计

很好

wqwerxser

一个简单的文本编辑器。(是在DEV C++下写的)//头文件//h#define CM_FILE_SAVEAS 9072#define CM_FILE_EXIT 9071#define CM_FILE_OPEN 9070#define CM_ABOUT 9069//主程序文件///*****************************************************/#include #pragma hdrstop#include "Mh"static char g_szClassName[] = "MyWindowClass";static HINSTANCE g_hInst = NULL;#define IDC_MAIN_TEXT 1001BOOL LoadFile(HWND hEdit, LPSTR pszFileName){ HANDLE hFile; BOOL bSuccess = FALSE; hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if(hFile != INVALID_HANDLE_VALUE) { DWORD dwFileSize; dwFileSize = GetFileSize(hFile, NULL); if(dwFileSize != 0xFFFFFFFF) { LPSTR pszFileText; pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1); if(pszFileText != NULL) { DWORD dwRead; if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL)) { pszFileText[dwFileSize] = 0; // Null terminator if(SetWindowText(hEdit, pszFileText)) bSuccess = TRUE; // It worked! } GlobalFree(pszFileText); } } CloseHandle(hFile); } return bSuccess;}BOOL SaveFile(HWND hEdit, LPSTR pszFileName){ HANDLE hFile; BOOL bSuccess = FALSE; hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if(hFile != INVALID_HANDLE_VALUE) { DWORD dwTextLength; dwTextLength = GetWindowTextLength(hEdit); if(dwTextLength > 0)// No need to bother if there's no { LPSTR pszText; pszText = (LPSTR)GlobalAlloc(GPTR, dwTextLength + 1); if(pszText != NULL) { if(GetWindowText(hEdit, pszText, dwTextLength + 1)) { DWORD dwWritten; if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL)) bSuccess = TRUE; } GlobalFree(pszText); } } CloseHandle(hFile); } return bSuccess;}BOOL DoFileOpenSave(HWND hwnd, BOOL bSave){ OPENFILENAME ofn; char szFileName[MAX_PATH]; ZeroMemory(&ofn, sizeof(ofn)); szFileName[0] = 0; lStructSize = sizeof(ofn); hwndOwner = hwnd; lpstrFilter = "Text Files (*xt)\0*xt\0All Files (**)\0**\0\0"; lpstrFile = szFileName; MaxFile = MAX_PATH; lpstrDefExt = "txt"; if(bSave) { Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; if(GetSaveFileName(&ofn)) { if(!SaveFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName)) { MessageBox(hwnd, "Save file ", "Error", MB_OK | MB_ICONEXCLAMATION); return FALSE; } } } else { Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; if(GetOpenFileName(&ofn)) { if(!LoadFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName)) { MessageBox(hwnd, "Load of file ", "Error", MB_OK | MB_ICONEXCLAMATION); return FALSE; } } } return TRUE;}LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){ switch(Message) { case WM_CREATE: CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_MAIN_TEXT, g_hInst, NULL); SendDlgItemMessage(hwnd, IDC_MAIN_TEXT, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0)); break; case WM_SIZE: if(wParam != SIZE_MINIMIZED) MoveWindow(GetDlgItem(hwnd, IDC_MAIN_TEXT), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); break; case WM_SETFOCUS: SetFocus(GetDlgItem(hwnd, IDC_MAIN_TEXT)); break; case WM_COMMAND: switch(LOWORD(wParam)) { case CM_FILE_OPEN: DoFileOpenSave(hwnd, FALSE); break; case CM_FILE_SAVEAS: DoFileOpenSave(hwnd, TRUE); break; case CM_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); break; case CM_ABOUT: MessageBox (NULL, "File Editor for Windows !\n Using the Win32 API" , "A", 0); } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, Message, wParam, lParam); } return 0;}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ WNDCLASSEX WndClass; HWND hwnd; MSG Msg; g_hInst = hInstance; WndCbSize = sizeof(WNDCLASSEX); WndCstyle = 0; WndClpfnWndProc = WndProc; WndCbClsExtra = 0; WndCbWndExtra = 0; WndChInstance = g_hInst; WndChIcon = LoadIcon(NULL, IDI_APPLICATION); WndChCursor = LoadCursor(NULL, IDC_ARROW); WndChbrBackground = (HBRUSH)(COLOR_WINDOW+1); WndClpszMenuName = "MAINMENU"; WndClpszClassName = g_szClassName; WndChIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&WndClass)) { MessageBox(0, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "A File Program", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, g_hInst, NULL); if(hwnd == NULL) { MessageBox(0, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return MwParam;}

什么意思啊??是文本控件??

java文本编辑器课程设计

为什么要设计文本编辑器,是练习吗?如果是初学练习的话,还是先熟悉语法和常用方法类吧。

import *;import *;import *;import *;import *; //Date neededimport PrintWriter;public class NotePad extends JFrame{ JTextArea jta; class newl implements ActionListener { public void actionPerformed(ActionEvent e) { setText(""); } } class openl implements ActionListener { public void actionPerformed(ActionEvent e) { JFileChooser jf=new JFileChooser(); showOpenDialog(NotePhis); } } //保存文件的监听 class savel implements ActionListener { public void actionPerformed(ActionEvent e) { JFileChooser jf = new JFileChooser(); showSaveDialog(NotePhis); } } //打印的监听 ? class printl implements ActionListener { public void actionPerformed(ActionEvent e) { // PrintWriter p = new PrintWriter(NotePhis); } } //退出记事本的监听 class exitl implements ActionListener { public void actionPerformed(ActionEvent e) { Sxit(0);//退出 } } //拷贝的监听 class copyl implements ActionListener { public void actionPerformed(ActionEvent e) { py(); } } //粘贴的监听 class pastel implements ActionListener { public void actionPerformed(ActionEvent e) { paste(); } } //剪切的监听 class cutl implements ActionListener { public void actionPerformed(ActionEvent e) { ut(); } } //查找的监听 //添加日期的监听 class datel implements ActionListener { public void actionPerformed(ActionEvent e) { Date d=new Date(); append(String()); } }//构造函数 public NotePad() { jta=new JTextArea("",24,40); JScrollPane jsp=new JScrollPane(jta); JMenuBar jmb=new JMenuBar(); JMenu mFile=new JMenu("File"); JMenu mEdit=new JMenu("Edit"); JMenuItem mNew=new JMenuItem("New",KeyEVK_N); mNaddActionListener(new newl()); mFadd(mNew); JMenuItem mOpen=new JMenuItem("Open",KeyEVK_O); mOaddActionListener(new openl()); mFadd(mOpen); JMenuItem mSave=new JMenuItem("Save"); mSaddActionListener(new savel()); mFadd(mSave); mFaddSeparator(); //添加分割线 JMenuItem mPrint = new JMenuItem("Print"); mPaddActionListener(new printl()); mFadd(mPrint); mFaddSeparator(); //添加分割线 JMenuItem mExit=new JMenuItem("Exit"); mEaddActionListener(new exitl()); mFadd(mExit); mFsetMnemonic(KeyEVK_F); //编辑菜单的子菜单的处理 JMenuItem jmi; jmi=new JMenuItem("Copy"); addActionListener(new copyl()); mEadd(jmi); jmi=new JMenuItem("Cut"); addActionListener(new cutl()); mEadd(jmi); jmi=new JMenuItem("Paste"); addActionListener(new pastel()); mEadd(jmi); mEaddSeparator(); //添加分割线 jmi=new JMenuItem("Find"); mEadd(jmi); jmi=new JMenuItem("FindNext"); mEadd(jmi); mEaddSeparator(); jmi=new JMenuItem("Select All"); mEadd(jmi); jmi=new JMenuItem("Date/Time"); addActionListener(new datel()); mEadd(jmi); add(mFile); add(mEdit); setJMenuBar(jmb); ContentPane()add(jsp); setSize(200,200); setVisible(true); } //主函数,程序入口点 public static void main(String s[]) { new NotePad(); } }

1 可以用列表 将程序中的函数列出-----这个好做,JList,JTable,JLabel等都可以。2 点击列表项 可以还原到程序的相关行----什么意思?1 新建函数时 可以弹出对话框 用以输入函数名和函数体-----这也好做,前者用JTextfield,后者就看你是函数意义了。2 并在程序中自动生成代码----什么代码?好像和2同,意义不清。你这里的函数的概念是什么?都包括什么符号?多变量?微积分?泛涵?总要有各定域才好。你的应用对象是中学生?大学生?还是财会人员?要对这里的函数有个明确表示,不然输入函数体的时候会有很多 exception的。当然如果是编程的函数的概念就好办了。只需要动态编译所输入的代码,看能否过就好。但话又说回来,面向对象的编程,就java来说重载,复用,还有继承,抽象,这个涵数和其他的关系如何考虑啊?能说说问题的出处?目的?需求?。。。。。。谢谢。

  • 索引序列
  • 文本编辑器设计
  • 行文本编辑器设计
  • 设计一个文本编辑器
  • 文本编辑器课程设计
  • java文本编辑器课程设计
  • 返回顶部