Главная страница
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.035 c
14-1091533035
}|{yk
2004-08-03 15:37
2004.08.22
4 уровневая архитектура???


3-1091175283
ksa2002
2004-07-30 12:14
2004.08.22
IB StoredProc


14-1091175327
Al-
2004-07-30 12:15
2004.08.22
плеер для samsung dvd karaoke


1-1091789377
xman
2004-08-06 14:49
2004.08.22
TreeView


3-1091002249
Koala
2004-07-28 12:10
2004.08.22
Посоветуйте хорошую книгу...