Delphi vs lazarus

Code transformation

Page 1 of 1

2 Replies - 10958 Views - Last Post: 20 June 2010 - 12:50 PM Rate Topic: -----

#1 sirko  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 31-May 10

Delphi vs lazarus

Posted 01 June 2010 - 10:01 AM

OK. I've got this program done in Delphi. The main thing what the program does is it manipulates with the text (changes colour, size, style). (It has rich edit and diolog components) But I need to get it dne in lazarus under linux. Theoretically the code was gonna be the same but I found out that there's no RichEdit compnent in lazarus. Any suggestions about how I can handle it?

Here's the code

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, ComCtrls;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
RichEdit1: TRichEdit;
File1: TMenuItem;
Open1: TMenuItem;
Save1: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Edit1: TMenuItem;
Cut1: TMenuItem;
Copy1: TMenuItem;
Paste1: TMenuItem;
Color1: TMenuItem;
ColorDialog1: TColorDialog;
N1: TMenuItem;
Font1: TMenuItem;
FontDialog1: TFontDialog;
Print1: TMenuItem;
Exit1: TMenuItem;
N2: TMenuItem;
New1: TMenuItem;
Help1: TMenuItem;
About1: TMenuItem;
N3: TMenuItem;
procedure Open1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure Cut1Click(Sender: TObject);
procedure Copy1Click(Sender: TObject);
procedure Paste1Click(Sender: TObject);
procedure Color1Click(Sender: TObject);
procedure Font1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure Print1Click(Sender: TObject);
procedure New1Click(Sender: TObject);
procedure RichEdit1Change(Sender: TObject);
procedure About1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
fChanged: boolean;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Open1Click(Sender: TObject);
begin
{Open a file}
If OpenDialog1.Execute then
begin
RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
Form1.Caption:=ExtractFileName(OpenDialog1.FileName);
fChanged:=False;
end;
end;

procedure TForm1.Save1Click(Sender: TObject);
begin
{Save a file}
if SaveDialog1.Execute then
begin
RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
fChanged:=False;
end;
end;

procedure TForm1.Cut1Click(Sender: TObject);
begin
{Cut text to clipboard}
RichEdit1.CutToClipboard;
end;

procedure TForm1.Copy1Click(Sender: TObject);
begin
{Copy text to clipboard}
RichEdit1.CopyToClipboard;
end;

procedure TForm1.Paste1Click(Sender: TObject);
begin
{Paste text from clipboard}
RichEdit1.PasteFromClipboard;
end;

procedure TForm1.Color1Click(Sender: TObject);
begin
{Set color of selected text}
if ColorDialog1.Execute then
Richedit1.SelAttributes.Color:=ColorDialog1.Color;
end;

procedure TForm1.Font1Click(Sender: TObject);
begin
{Set global font}
if FontDialog1.Execute then
Richedit1.Font:=FontDialog1.Font;
end;

procedure TForm1.Exit1Click(Sender: TObject);
begin
{close the app}
Close;
end;

procedure TForm1.Print1Click(Sender: TObject);
begin
{Print the document to default printer}
RichEdit1.Print(Form1.Caption);
end;

procedure TForm1.New1Click(Sender: TObject);
begin
{New document}
if fChanged then
if MessageDlg('Save changes?',mtConfirmation,[mbYes,mbNo],0)=mrYes then
Save1Click(nil);
RichEdit1.Lines.Clear;
Form1.Caption:='New';
end;

procedure TForm1.RichEdit1Change(Sender: TObject);
begin
{Flag document change}
if not(fChanged) then
begin
fChanged:=True;
Form1.Caption:=Form1.Caption+' *';
end; {if}
end;

procedure TForm1.About1Click(Sender: TObject);
begin
//Show an about form here...
end;

end.

Is This A Good Question/Topic? 0
  • +

Replies To: Delphi vs lazarus

#2 calvinthedestroyer  Icon User is offline

  • D.I.C Lover

Reputation: 167
  • View blog
  • Posts: 1,908
  • Joined: 13-October 07

Re: Delphi vs lazarus

Posted 09 June 2010 - 08:21 AM

uh,, Lazarus is a text editor. you should be able to edit, copy and past your code right into the Lazarus IDE. If you are moving the file from windows to Linux then you should save your code as a standard text file and then move it to the Linux box. from there you can edit copy and past the code into the IDE.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Thomas G*


Reputation:

Re: Delphi vs lazarus

Posted 20 June 2010 - 12:50 PM

View Postcalvinthedestroyer, on 09 June 2010 - 07:21 AM, said:

uh,, Lazarus is a text editor. you should be able to edit, copy and past your code right into the Lazarus IDE. If you are moving the file from windows to Linux then you should save your code as a standard text file and then move it to the Linux box. from there you can edit copy and past the code into the IDE.


I guess you missed that Lazarus is an IDE using FreePascal. This is an open source effort to duplicate Delphi's capabilities.

@sirco:
They have a SynEdit component, which is even more powerful. You should be able to use that instead.
Was This Post Helpful? 0

Page 1 of 1