Главная страница
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.056 c
3-1091042715
GanibalLector
2004-07-28 23:25
2004.08.22
зависание приложения при выполнении запроса


1-1091673946
paa
2004-08-05 06:45
2004.08.22
Memo


1-1091682277
mixam
2004-08-05 09:04
2004.08.22
работа с log файлами


3-1090587495
MORA
2004-07-23 16:58
2004.08.22
целостность БД


14-1091692034
GRAND25
2004-08-05 11:47
2004.08.22
Мы тут все отдыхаем, что ли?