Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2021-12

How to convert Delphi program with TRichEdit?

13 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I need to port an old Delphi program to FPC/Lazarus and it contains two TRichEdit components.

When I try to open the form in Lazarus 2.0.12 on Windows 10 with Fpc 3.2.0 I get an error because the TRichEdit component does not exist....

Is there some non-standard package I could install (from OLPM or similar) in order to get it working again?

I have a new laptop now and I have no new Delphi version installed (except for Delphi 7 with the no-nonsense license). I am only using Fpc + Lazarus nowadays.

Another question while I am here:
---------------------------------

The form I have problems with is a special calculation sheet in one single form, which is part of the source program.
But I only need to port this form into the new Lazarus program so I tried to create a new program from scratch and intended to replace the default form as the main form.
But I don't know really how to do this...

So How can I:

1) Replace the main form of a Lazarus program with another form? or
2) Create a new program in Lazarus where I can specify an existing form as the main program form.

Either of these will work, but I don't really know how to do any of them.

Bo Berglund Developer in Sweden

Reply by email

R.Smith
to Bo Berglund
Bo Berglund wrote 8 lines
I need to port an old Delphi program to FPC/Lazarus and it contains two TRichEdit components. When I try to open the form in Lazarus 2.0.12 on Windows 10 with Fpc 3.2.0 I get an error because the TRichEdit component does not exist.... Is there some non-standard package I could install (from OLPM or similar) in order to get it working again?

Not really. The problem is TRichEdit was just a wrapper for the MS Windows RichEdit component, which was born before the days of HTML componenets, so far inferior to anything new. It does not exist anywhere else in the world and so not useful on a cross-platform development system. Not sure if anybody reverse-engineered the RichEdit functionality, but if Google doesn't know then I am relatively sure there isn't.

Show quoted text 22 lines
I have a new laptop now and I have no new Delphi version installed (except for Delphi 7 with the no-nonsense license). I am only using Fpc + Lazarus nowadays. Another question while I am here: --------------------------------- The form I have problems with is a special calculation sheet in one single form, which is part of the source program. But I only need to port this form into the new Lazarus program so I tried to create a new program from scratch and intended to replace the default form as the main form. But I don't know really how to do this... So How can I: 1) Replace the main form of a Lazarus program with another form? or 2) Create a new program in Lazarus where I can specify an existing form as the main program form. Either of these will work, but I don't really know how to do any of them.

This is quick to do -
via the GUI:

In the Project Options, simply go to "Forms" and make sure the topmost one is the one you want to load as your main form.

via Code:

Open the program file (Project --> View Source) and make sure in the code section the very first "Application.CreateForm(...)" that appears is the one for your desired main form.

Basically TApplication regards the first form it opens as the "main" form, which simply means that that form is shown automatically first (unless specified not to) and that it will exit when that form closes (and a few more small things).

Reply by email

Dmitry Boyarintsev
to Bo Berglund: I need to port an old Delphi program to FPC/Lazarus and it contains two TRichEdit…

On Wednesday, December 8, 2021, Bo Berglund via lazarus <

Show quoted text 6 lines
wrote: Is there some non-standard package I could install (from OLPM or similar) in order to get it working again?

you might want to try TRichMemo

it provides some sort of compatibility with TRichEdit https://wiki.freepascal.org/RichMemo#TRichEditForMemo

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20211208/de9fe877/attachment.html>

Reply by email

Bo Berglund
to R.Smith: Not really. The problem is TRichEdit was just a wrapper for the MS Windows RichEdit…
"R.Smith wrote 14 lines
> So How can I: > > 1) Replace the main form of a Lazarus program with another form? > or > 2) Create a new program in Lazarus where I can specify an existing form as the > main program form. > > Either of these will work, but I don't really know how to do any of them. This is quick to do - via the GUI: In the Project Options, simply go to "Forms" and make sure the topmost one is the one you want to load as your main form.

Wel, my form is not shown here either as active or available. I added the unit via Project Inspector using the Add button...

Show quoted text 5 lines
via Code: Open the program file (Project --> View Source) and make sure in the code section the very first "Application.CreateForm(...)" that appears is the one for your desired main form.

In the source I had to:
- Add the form unit to the uses clause and remove Unit1
- Change the Application.CreateForm call to use the specific form
- Erase Form1 from the lpr file
- Remove Unit1 in Project Inspector.

Basically TApplication regards the first form it opens as the "main" form, which simply means that that form is shown automatically first (unless specified not to) and that it will exit when that form closes (and a few more small things).

OK, so now I have to solve the dependencies that popped up regarding used units in the now main form...

Bo Berglund Developer in Sweden

Reply by email

John Landmesser
to Dmitry Boyarintsev: On Wednesday, December 8, 2021, Bo Berglund via lazarus < you might want to try TRichMemo…
Dmitry Boyarintsev wrote 16 lines
On Wednesday, December 8, 2021, Bo Berglund via lazarus wrote: Is there some non-standard package I could install (from  OLPM or similar) in order to get it working again?  you might want to try TRichMemo it provides some sort of compatibility with TRichEdit https://wiki.freepascal.org/RichMemo#TRichEditForMemo thanks, Dmitry

If i remember correct  TRichMemo won't be usable on Linux. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20211209/47809926/attachment.html>

Reply by email

Bo Berglund
to R.Smith: Not really. The problem is TRichEdit was just a wrapper for the MS Windows RichEdit…
"R.Smith wrote 11 lines
> Is there some non-standard package I could install (from OLPM or similar) in > order to get it working again? Not really. The problem is TRichEdit was just a wrapper for the MS Windows RichEdit component, which was born before the days of HTML componenets, so far inferior to anything new. It does not exist anywhere else in the world and so not useful on a cross-platform development system. Not sure if anybody reverse-engineered the RichEdit functionality, but if Google doesn't know then I am relatively sure there isn't.

OK,
I do not think I need a TRichEdit just to show the data, a TMemo would probably suffice as long as I can set a font like Licida Console or other fixed width font.

But I also need to be able to set the text selection in code...

The application is used to display a panel of the hex representation of the binary data loaded from file.

When the user selects a data item in a separate item list the corresponding hex values in the panel shall be selected. The amount of data varies from item to item and this is the reason for the display.

Also, if a user clicks on a value in the hex list the corresponding data item in the data list shall be selected and the full scope of the data item selected in the hex view.

So I need a display component that can handle this:
- an address panel to the left of the main panel, not part of the list
- a main panel showing the hex data in rows of 16 values each
- the data lines shall scroll in sync with the address panel
- the hex values of a data item shall be selected in the main panel
- if the user clicks in the hex panel the clicked item shall be selected

Problems:

Can TMemo handle this?

If not is there another Lazarus component that can be used?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Luca Olivetti
Luca Olivetti wrote 9 lines
El 9/12/21 a les 15:05, Bo Berglund via lazarus ha escrit: > > If not is there another Lazarus component that can be used? Maybe you could use TMPHexEditorEx https://github.com/michalgw/mphexeditor

I went there but I found no documentation...

There is a doc/MPHexEditor.chm file but it does not display anything except headings on my Windows-10 PC...

How can I use this?

Notice that I do not want to *edit* any data just display them in a matrix where the bytes corresponding to a data item are highlighted.

Bo Berglund Developer in Sweden

Reply by email

Luca Olivetti
to Bo Berglund

El 9/12/21 a les 16:19, Bo Berglund via lazarus ha escrit:

Show quoted text 14 lines
On Thu, 9 Dec 2021 16:01:01 +0100, Luca Olivetti via lazarus wrote: > El 9/12/21 a les 15:05, Bo Berglund via lazarus ha escrit: > >> >> If not is there another Lazarus component that can be used? > > Maybe you could use TMPHexEditorEx > > https://github.com/michalgw/mphexeditor > I went there but I found no documentation...

there's a chm file (which I didn't use) and a couple of examples. Then there's google, duckduckgo and other search engines.

There is a doc/MPHexEditor.chm file but it does not display anything except headings on my Windows-10 PC...

Ah, Ok, as I didn't use it (I didn't even see it was there) I cannot tell, I just used the examples and looked at the properties in the object inspector.

Show quoted text 5 lines
How can I use this? Notice that I do not want to *edit* any data just display them in a matrix where the bytes corresponding to a data item are highlighted.

It's up to you to check it out. If, by adjusting some properties, can do what you want, good, if not you'll have to look for something else :-(

I can only say that it has some bugs: in my case, I tried to adjust the BytesPerColumn property at design time and it made the form unloadable. I just set it during FormShow and it's fine (for my needs).

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Dmitry Boyarintsev
to John Landmesser: If i remember correct  TRichMemo won't be usable on Linux. -------------- next part…

On Thu, Dec 9, 2021 at 5:23 AM John Landmesser via lazarus <

wrote: If i remember correct TRichMemo won't be usable on Linux.

According to Bo's needs (showing colored Hex values) RichMemo will work just fine for Linux. (Both Qt and Gtk2)

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20211209/73334dbf/attachment.html>

Reply by email

Bo Berglund
to Dmitry Boyarintsev
Dmitry Boyarintsev wrote 11 lines
> Is there some non-standard package I could install (from OLPM or similar) > in > order to get it working again? > you might want to try TRichMemo it provides some sort of compatibility with TRichEdit https://wiki.freepascal.org/RichMemo#TRichEditForMemo thanks, Dmitry

I looked at the wiki page:
https://wiki.freepascal.org/RichMemo

And the Download section says:
"The easiest way to install the stable version of the component is via the Online-Package-Manager"

THis was the best way, so I did this and then I replaced the TRichEdit panels with the TRichMemo instead.

With some small tweaks it seems like it is now working! :-)

THANK YOU for your pointer towards this component! Much obliged!

Bo Berglund Developer in Sweden

Reply by email