轻安qa 2022-12-27 11:39 采纳率: 50%
浏览 67
已结题

mfc的文本编辑程序

img


这是一道基于MFC的用对话框及其中的编辑框和按钮控件的题,这个怎么做啊,急!

  • 写回答

4条回答 默认 最新

  • 赵4老师 2022-12-27 14:08
    关注
    仅供参考:
    CEdit Class Members
    Construction
    Attributes
    Operations
    Clipboard Operations
    
    Construction
    
    CEdit Constructs a CEdit control object. 
    Create Creates the Windows edit control and attaches it to the CEdit object. 
    
    
    CEdit Attributes
    
    CanUndo Determines whether an edit-control operation can be undone. 
    GetLineCount Retrieves the number of lines in a multiple-line edit control. 
    GetModify Determines whether the contents of an edit control have been modified. 
    SetModify Sets or clears the modification flag for an edit control. 
    GetRect Gets the formatting rectangle of an edit control. 
    GetSel Gets the starting and ending character positions of the current selection in an edit control. 
    GetHandle Retrieves a handle to the memory currently allocated for a multiple-line edit control. 
    SetHandle Sets the handle to the local memory that will be used by a multiple-line edit control. 
    SetMargins Sets the left and right margins for this CEdit. 
    GetMargins Gets the left and right margins for this CEdit. 
    SetLimitText Sets the maximum amount of text this CEdit can contain. 
    GetLimitText Gets the maximum amount of text this CEdit can contain. 
    PosFromChar Retrieves the coordinates of the upper-left corner of a specified character index. 
    CharFromPos Retrieves the line and character indices for the character closest to a specified position. 
    GetLine Retrieves a line of text from an edit control. 
    GetPasswordChar Retrieves the password character displayed in an edit control when the user enters text. 
    GetFirstVisibleLine Determines the topmost visible line in an edit control. 
    
    
    CEdit Operations
    
    EmptyUndoBuffer Resets (clears) the undo flag of an edit control. 
    FmtLines Sets the inclusion of soft line-break characters on or off within a multiple-line edit control. 
    LimitText Limits the length of the text that the user may enter into an edit control. 
    LineFromChar Retrieves the line number of the line that contains the specified character index. 
    LineIndex Retrieves the character index of a line within a multiple-line edit control. 
    LineLength Retrieves the length of a line in an edit control. 
    LineScroll Scrolls the text of a multiple-line edit control. 
    ReplaceSel Replaces the current selection in an edit control with the specified text. 
    SetPasswordChar Sets or removes a password character displayed in an edit control when the user enters text. 
    SetRect Sets the formatting rectangle of a multiple-line edit control and updates the control. 
    SetRectNP Sets the formatting rectangle of a multiple-line edit control without redrawing the control window. 
    SetSel Selects a range of characters in an edit control. 
    SetTabStops Sets the tab stops in a multiple-line edit control. 
    SetReadOnly Sets the read-only state of an edit control. 
    
    
    CEdit Clipboard Operations
    
    Undo Reverses the last edit-control operation. 
    Clear Deletes (clears) the current selection (if any) in the edit control. 
    Copy Copies the current selection (if any) in the edit control to the Clipboard in CF_TEXT format. 
    Cut Deletes (cuts) the current selection (if any) in the edit control and copies the deleted text to the Clipboard in CF_TEXT format. 
    Paste Inserts the data from the Clipboard into the edit control at the current cursor position. Data is inserted only if the Clipboard contains data in CF_TEXT format. 
    
    
    CEdit Overview |  Base Class Members |  Hierarchy Chart
     
    Clipboard: Using the Windows Clipboard
    Home |  Overview |  How Do I
    
    This article describes how to use the standard Windows Clipboard API within your MFC application.
    
    Most applications for Windows support cutting or copying data to the Windows Clipboard and pasting data from the Clipboard. The Clipboard data formats vary among applications. The framework supports only a limited number of Clipboard formats for a limited number of classes. You will normally implement the Clipboard-related commands  Cut, Copy, and Paste — on the Edit menu for your view. The class library defines the command IDs for these commands: ID_EDIT_CUT, ID_EDIT_COPY, and ID_EDIT_PASTE. Their message-line prompts are also defined.
    
    Messages and Commands in the Framework, explains how to handle menu commands in your application by mapping the menu command to a handler function. As long as your application does not define handler functions for the Clipboard commands on the Edit menu, they remain disabled. To write handler functions for the Cut and Copy commands, implement selection in your application. To write a handler function for the Paste command, query the Clipboard to see whether it contains data in a format your application can accept. For example, to enable the Copy command, you might write a handler something like the following:
    
    void CMyView::OnEditCopy()
    {
      if ( !OpenClipboard() )
      {
        AfxMessageBox( "Cannot open the Clipboard" );
        return;
      }
      // Remove the current Clipboard contents
      if( !EmptyClipboard() )
      {
        AfxMessageBox( "Cannot empty the Clipboard" );
        return;
      }
      // ...
      // Get the currently selected data
      // ...
      // For the appropriate data formats...
      if ( ::SetClipboardData( CF_??, hData ) == NULL )
      {
        AfxMessageBox( "Unable to set Clipboard data" );
        CloseClipboard();
        return;
      }
      // ...
      CloseClipboard();
    }
    
    The Cut, Copy, and Paste commands are only meaningful in certain contexts. The Cut and Copy commands should be enabled only when something is selected, and the Paste command only when something is in the Clipboard. You can provide this behavior by defining update handler functions that enable or disable these commands depending on the context. For more information, see How to Update User-Interface Objects.
    
    The Microsoft Foundation Class Library does provide Clipboard support for text editing with the CEdit and CEditView classes. The OLE classes also simplify implementing Clipboard operations that involve OLE items. For more information on the OLE classes, see Clipboard: Using the OLE Clipboard Mechanism.
    
    Implementing other Edit menu commands, such as Undo (ID_EDIT_UNDO) and Redo (ID_EDIT_REDO), is also left to you. If your application does not support these commands, you can easily delete them from your resource file using the Visual C++ resource editors.
    
    What do you want to know more about?
    Copying and pasting data
    
    
    Using the OLE Clipboard mechanism 
    
    
    
    评论

报告相同问题?

问题事件

  • 系统已结题 1月4日
  • 创建了问题 12月27日

悬赏问题

  • ¥15 mySQL5.7.34安装遇到的问题
  • ¥15 结构功能耦合指标计算
  • ¥20 visual studio中c语言用ODBC链接SQL SERVER
  • ¥50 AI大模型精调(百度千帆、飞浆)
  • ¥15 非科班怎么跑代码?如何导数据和调参
  • ¥15 福州市的全人群死因监测点死亡原因报表
  • ¥15 Altair EDEM中生成一个颗粒,并且各个方向没有初始速度
  • ¥15 系统2008r2 装机配置推荐一下
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊