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 网页操作自动化, 图像分析破解,游戏开发
  • 相关阅读:
    LoadScript
    Mac终端Terminal调用Sublime Text
    jquery ajax 提交 FormData
    ps切图设置
    bootstrap-select搜索框输入中文
    Homebrew安装
    清空file input框
    javascript 随机数区间
    Canvas与Image互转
    html空格小结
  • 原文地址:https://www.cnblogs.com/delphi-xe5/p/5440272.html
Copyright © 2011-2022 走看看