zoukankan      html  css  js  c++  java
  • RichEdit 学习

    procedure TForm1.AddText(RichEdit: TRichEdit; Str: string;
    TextColor: TColor = clBlack;
    FontName: string = '宋体';
    Size: integer = 9;
    Style: TFontStyles = []);
    var
    nStartOffset: integer;
    begin
    with RichEdit1 do
    begin
    if Lines.Count = 0 then
    nStartOffset:= 0
    else
    nStartOffset:= Length(Text); //Lines.Insert(0, Str);
    Lines.Add( Str );
    SelStart:= nStartOffset;
    SelLength:= Length( Str );
    //Set Attribues
    SelAttributes.Color:= TextColor;
    SelAttributes.Name:= FontName;
    SelAttributes.Size:= Size;
    SelAttributes.Style:= Style;

    SelLength:= 0;
    //滚动到最下方,模拟 CTRL+END 键,总不好使呢!???
    PostMessage(RichEdit1.Handle, WM_KEYDOWN, VK_CONTROL, 0);
    PostMessage(RichEdit1.Handle, WM_KEYDOWN, VK_NEXT, 0);
    PostMessage(RichEdit1.Handle, WM_KEYUP, VK_NEXT, 0);
    PostMessage(RichEdit1.Handle, WM_KEYUP, VK_CONTROL, 0);
    end;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    AddText(RichEdit1, '缺省文字');
    AddText(RichEdit1, '红色文字', clRed);
    AddText(RichEdit1, '绿色,华文行楷', clGreen, '华文行楷');
    AddText(RichEdit1, '蓝色,黑体,24', clBlue, '黑体',24);
    AddText(RichEdit1, '紫色,华文彩云,32', clFuchsia, '华文彩云',32,
    [fsBold, fsItalic, fsUnderline]);
    AddText(RichEdit1, '黄色文字', clYellow);
    end;

    delphi lazarus opengl 网页操作自动化, 图像分析破解,游戏开发
  • 相关阅读:
    换个角度看Salesforce之基础配置学习笔记(二)
    换个角度看Salesforce之基础配置学习笔记(一)
    C# LINQ学习笔记
    Oracle使用总结
    UML图及Visio 2010使用总结
    常见的DOS命令
    ansible笔记
    jsoncpp1.9.4源码解析
    fabric链码
    fabric数据结构
  • 原文地址:https://www.cnblogs.com/delphi-xe5/p/5440272.html
Copyright © 2011-2022 走看看