10-02-2009, 01:01 PM
السلام عليكم
شكرا أخونا عبد العزيز لكنني لم أفهم قصدك ما علاقة MaxLength بتحديد حجم النص الظاهر.
لقد وجدت الحل واستخدمت متغيرات رقمية:
وهذه دالة تعيد عدد الأسطر الظاهرة:
عموما شكرا كثيرا على التجاوب.
شكرا أخونا عبد العزيز لكنني لم أفهم قصدك ما علاقة MaxLength بتحديد حجم النص الظاهر.
لقد وجدت الحل واستخدمت متغيرات رقمية:
PHP كود :
var
IndexCurrentLine, PosCurrentLine,
CountVisibleLine, IndexFirstVisible,
IndexLastVisible, PosFirstVisible,
PosLastVisibleLine: Integer;
with RichEdit1 do begin
IndexCurrentLine := GetCaretPos.Y;//or Perform(EM_LINEFROMCHAR, SelStart, 0);
PosCurrentLine := Perform(EM_LINEINDEX, IndexCurrentLine,0);
IndexFirstVisible := Perform(EM_GETFIRSTVISIBLELINE, 0, 0);
PosFirstVisible := Perform(EM_LINEINDEX, IndexFirstVisible,0);
CountVisibleLine := (Height div Abs(Font.Height))-1;
IndexLastVisible := RE_GetLastVisibleLine(RichEdit1);
PosLastVisibleLine:= GetLinesLength(IndexFirstVisible, IndexLastVisible);
end;
PHP كود :
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;

