Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.08.22;
Скачать: CL | DM;

Вниз

RichEdit   Найти похожие ветки 

 
vakir77   (2004-08-10 16:21) [0]

Здравствуйте, можно ли программно перевести курсор в видимую часть текста. Т.е при скроллинге текста мышью, курсор остается на первой строке, как сделать что бы он передвигался на первую видимую строку в RichEdit-е.


 
Cosinus ©   (2004-08-10 16:29) [1]

Переместить курсор в TRichEdit на нужную позицию

// You can move the caret in a TRichEdit component by using this code :

procedure RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
begin
  RichEdit.SelStart := RichEdit.Perform(EM_LINEINDEX, LineNumber, 0) + CharNumber);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RichEdit_MoveTo(RichEdit1,2,5);
  Application.ProcessMessages;
  RichEdit1.SetFocus;
end;

Получить первую или последнюю видимую строку в TRichEdit

function RE_GetLastVisibleLine(RichEdit: TRichEdit): Integer;
const
  EM_EXLINEFROMCHAR = WM_USER + 54;
var
  r: TRect;
  i: Integer;
begin
  {
  The EM_GETRECT message retrieves the formatting rectangle
  of an edit control.
 }
  RichEdit.Perform(EM_GETRECT, 0, Longint(@r));
  r.Left := r.Left + 1;
  r.Top  := r.Bottom - 2;
  {
   The EM_CHARFROMPOS message retrieves information about the character
   closest to a specified point in the client area of an edit control
 }
  i := RichEdit.Perform(EM_CHARFROMPOS, 0, Integer(@r.topleft));
  {
   The EM_EXLINEFROMCHAR message determines which
   line contains the specified character in a rich edit control
 }
  Result := RichEdit.Perform(EM_EXLINEFROMCHAR, 0, i);
end;

{
 Sending the EM_GETFIRSTVISIBLELINE message to a multi-line edit control
 finds out which line is the first line visible.
 This is the line that is currently displayed at the top of the control.
}

function RE_GetFirstVisibleLine(RichEdit: TRichEdit): Integer;
begin
  Result := RichEdit.Perform(EM_GETFIRSTVISIBLELINE, 0, 0);
end;


 
vakir77   (2004-08-10 16:48) [2]

to Cosinus © большое спасибо



Страницы: 1 вся ветка

Текущий архив: 2004.08.22;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.032 c
14-1091701094
syte_ser78
2004-08-05 14:18
2004.08.22
иконки технологической арматуры


3-1090997226
unick111
2004-07-28 10:47
2004.08.22
Горизонтальный DBGrid


9-1082992489
S.W.I.N.E.
2004-04-26 19:14
2004.08.22
Алгоритм созжания карты


1-1092058858
ПЛОВ
2004-08-09 17:40
2004.08.22
Вопрос по чтению строк из текстовых файлов


11-1079638623
nester
2004-03-18 22:37
2004.08.22
Как пользоваться KOLTabControl.