求范例源代码。

解决方案 »

  1.   

    procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key in ['0'..'9'] then
      begin
        richedit1.SelAttributes.Size:=5;
      end
      else richedit1.SelAttributes.Size:=10;
    end;
      

  2.   

    crossbow的那种只能实现下标,上标还是没办法啊。
      

  3.   

    //一个老外的东东,不知是否可用??typeTCharacterFormat = (CFM_Superscript, CFM_Subscript, CFM_Normal);procedure RE_SetCharFormat(RichEdit: TRichEdit; CharacterFormat: TCharacterFormat);var// The CHARFORMAT structure contains information about// character formatting in a rich edit control.Format: TCharFormat;beginFillChar(Format, SizeOf(Format), 0);with Format dobegincbSize := SizeOf(Format);dwMask := CFM_OFFSET;// Character offset, in twips, from the baseline.// If the value of this member is positive,// the character is a superscript;// if it is negative, the character is a subscript.case CharacterFormat ofCFM_Superscript: yOffset := 60;CFM_Subscript: yOffset := -60;CFM_Normal: yOffset := 0;end;end;// The EM_SETCHARFORMAT message sets character formatting in a rich edit control.// SCF_SELECTION: Applies the formatting to the current selectionRichedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));end;// Examples:// Beispiele:// Apply Superscript to the current selection// Markierte Zeichen hoch stellenprocedure TForm1.Button1Click(Sender: TObject);beginRE_SetCharFormat(RichEdit1, CFM_Superscript);end;// Apply Subscript to the current selection// Markierte Zeichen tief stellenprocedure TForm1.Button2Click(Sender: TObject);beginRE_SetCharFormat(RichEdit1, CFM_Subscript);end;