27-01-2024, 03:29 AM
(24-01-2024, 08:12 PM)bibill كتب : السلام عليكم و رحمة الله :
الموضوع : كيف يمكن انشاء محرر نصوص بحيث أقوم بالتحكم في نوع و حجم و عرض الخط ....
تقريبا مثل محرر النصوص هذا الخاص بالموقع .
بحيث أحفظ الملف RTF
السلام عليكم
جرب:
كود :
procedure TForm1.FormCreate(Sender: TObject);
begin
// Configure the font type ComboBox with the available options
ComboBoxFont.Items := Screen.Fonts;
ComboBoxFont.ItemIndex := 0; // Default font
// Configure the font size ComboBox with the available options
ComboBoxSize.Items.Add('10');
ComboBoxSize.Items.Add('12');
ComboBoxSize.Items.Add('14');
ComboBoxSize.ItemIndex := 0; // Default size
// Configure the font width TrackBar
TrackBarWidth.Min := 1;
TrackBarWidth.Max := 10;
TrackBarWidth.Position := 5; // Default width
end;
procedure TForm1.ComboBoxFontChange(Sender: TObject);
begin
// Apply the font type change to the RichEdit component
RichEdit1.SelAttributes.Name := ComboBoxFont.Text;
end;
procedure TForm1.ComboBoxSizeChange(Sender: TObject);
begin
// Apply the font size change to the RichEdit component
RichEdit1.SelAttributes.Size := StrToInt(ComboBoxSize.Text);
end;
procedure TForm1.TrackBarWidthChange(Sender: TObject);
begin
// Apply the font width change to the RichEdit component
RichEdit1.SelAttributes.Width := TrackBarWidth.Position;
end;
procedure TForm1.ButtonSaveClick(Sender: TObject);
var
SaveDialog: TSaveDialog;
begin
SaveDialog := TSaveDialog.Create(Self);
try
SaveDialog.Filter := 'RTF Files|*.rtf';
if SaveDialog.Execute then
RichEdit1.Lines.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;الخوف من أي محاولة جديدة طريق حتمي للفشل.

