Sign in Join

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

Mailing lists / lazarus / 2023-02

converted Delphi 7 project: add new form not possible?

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

John Landmesser
to John Landmesser

Sorry sysinfo missing:

Lazarus:
Lazarus 2.3.0 (rev main-2_3-2873-g17b66f88c4) FPC 3.2.2 x86_64-linux-gtk2

On Manjaro XFCE Linux:
System:
? Kernel: 6.1.1-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.0 Desktop: Xfce v: 4.18.0
??? Distro: Manjaro Linux base: Arch Linux
Machine:
? Type: Laptop System: LENOVO product: 81RS v: Lenovo Yoga S740-14IIL serial: <superuser required>
? Mobo: LENOVO model: LNVNB161216 v: SDK0J40709 WIN serial: <superuser required> UEFI: LENOVO
??? v: BYCN39WW date: 05/28/2021
Battery:
? ID-1: BAT0 charge: 63.7 Wh (97.5%) condition: 65.3/62.0 Wh (105.3%) volts: 17.1 min: 15.4
??? model: LGC L19L4PD2 status: full
CPU:
? Info: quad core model: Intel Core i7-1065G7 bits: 64 type: MT MCP arch: Ice Lake rev: 5 cache:
??? L1: 320 KiB L2: 2 MiB L3: 8 MiB
? Speed (MHz): avg: 1367 high: 1500 min/max: 400/3900 cores: 1: 1299 2: 1300 3: 1500 4: 1500
??? 5: 1275 6: 1500 7: 1300 8: 1262 bogomips: 23968 ? Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx

Delphi 7 Pro on Windows 10 Home

John Landmesser wrote 22 lines
Hi, I tried to extend an existing and converted? Delphi 7 project by adding new form to the converted Delphi 7 project. But that leads to an AV-error if i try to show this new form by code! Sample not yet converted? Delphi 7 project: I hope i configured my google drive correct so this link works for downloading?! https://drive.google.com/file/d/1PgY5sR9cXnhtQQgG5zpfMd2lEFg65kkN/view?usp=sharing Tipps are welcome John Landmesser

Reply by email

Vojtěch Čihák
to John Landmesser

Hi,
?
it is my new experience with Delphi project convertor. I noticed that:
The converted unit1 has:
?TForm1 = class(TForm)
? ? ListBox1: TListBox;
? ? Button1: TButton;? ? ?
? ?....
And when I add a new form, i.e. unit2, it has also TForm1 = class(TForm)
? private
? ....
?
Normally (common Lazarus project) it creates unit2 + Form2. ?
Vojt?ch
??
______________________________________________________________

Show quoted text 7 lines
Od: "John Landmesser via lazarus" Komu: Datum: 24.02.2023 21:51 P?edm?t: Re: [Lazarus] converted Delphi 7 project: add new form not possible? John Landmesser

Reply by email

John Landmesser
to Vojtěch Čihák
Vojt?ch ?ih?k wrote 29 lines
Hi, it is my new experience with Delphi project convertor. I noticed that: The converted unit1 has: ?TForm1 = class(TForm) ? ? ListBox1: TListBox; ? ? Button1: TButton; ? ?.... And when I add a new form, i.e. unit2, it has also TForm1 = class(TForm) ? private ? .... Normally (common Lazarus project) it creates unit2 + Form2. Vojt?ch

That is correct, but when? you are saving the new form you can give it new names?!

Show quoted text 18 lines
______________________________________________________________ > Od: "John Landmesser via lazarus" > Komu: > Datum: 24.02.2023 21:51 > P?edm?t: Re: [Lazarus] converted Delphi 7 project: add new form not possible? > > John Landmesser > -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20230224/4d332ea5/attachment-0001.htm>

Reply by email

Vojtěch Čihák
to John Landmesser

Yes, files are unit2.pas and unit2.lfm so you must manually rename the class and the form. ?
I tried to rename the second Form1 to Form2 in Object Inspector but it automatically changed line Application.CreateForm(TForm1, Form1);
to
Application.CreateForm(TForm2, Form2); in ProjectD7.lpr Buit this line autocreates the first Form1!
?
So it's a little mess. Anyway, Lazarus shouldn't create two TForm1 classes in one project. ?
V.
______________________________________________________________

Show quoted text 5 lines
Od: "John Landmesser via lazarus" Komu: Datum: 24.02.2023 22:26 P?edm?t: Re: [Lazarus] converted Delphi 7 project: add new form not possible?

Am 24.02.23 um 22:21 schrieb Vojt?ch ?ih?k via lazarus:Hi, ?
it is my new experience with Delphi project convertor. I noticed that:
The converted unit1 has:
?TForm1 = class(TForm)
? ? ListBox1: TListBox;
? ? Button1: TButton;? ? ?
? ?....
And when I add a new form, i.e. unit2, it has also TForm1 = class(TForm)
? private
? ....
?
Normally (common Lazarus project) it creates unit2 + Form2. ?
Vojt?ch
That is correct, but when? you are saving the new form you can give it new names?! ?
?
______________________________________________________________

Show quoted text 7 lines
Od: "John Landmesser via lazarus" Komu: Datum: 24.02.2023 21:51 P?edm?t: Re: [Lazarus] converted Delphi 7 project: add new form not possible? John Landmesser

Reply by email

John Landmesser
to Vojtěch Čihák

.. and now the most interesting part:

Try to show form2 with the button on Delphi 7 converted form.

Before that add under implementation section:
uses unit2;

Now i get the AV-Error message if i try to show form2!

You too see an error mesage?

Reply by email

Werner Pamler
to John Landmesser: I tried to extend an existing and converted? Delphi 7 project by adding new form to the…
John Landmesser wrote 6 lines
Hi, I tried to extend an existing and converted? Delphi 7 project by adding new form to the converted Delphi 7 project. But that leads to an AV-error if i try to show this new form by code!

I normally convert Delphi projects manually - it's more work, but I know what's happening then... And the manual conversion of your test project worked flawlessly.

But anyway: When trying to use the IDE's Delphi converter I saw two problems:

/1/ The newly added form is named Form1 (type TForm1) and this screws up the entire project since these identifiers already exist in the Delphi project. I can circumvent this issue when I close the IDE after conversion and create the new form only after a restart.

/2/ But this does not prevent the other issue: The IDE refuses to add the new form to the list of auto-created forms, and therefore a call of "Form2.Show" in the OnClick handler of your button on Form1 must fail. I have no idea what prevents the new form from being auto-created. As a work-around I added the line "Application.CreateForm(TForm2, Form2);" to the project unit manually (and Unit2 to its uses clause). - This way it works.

Please file a bug report.

Reply by email

John Landmesser
to Werner Pamler
Werner Pamler wrote 30 lines
Am 24.02.2023 um 21:35 schrieb John Landmesser via lazarus: > Hi, > > I tried to extend an existing and converted? Delphi 7 project by adding > new form to the converted Delphi 7 project. > > But that leads to an AV-error if i try to show this new form by code! I normally convert Delphi projects manually - it's more work, but I know what's happening then... And the manual conversion of your test project worked flawlessly. But anyway: When trying to use the IDE's Delphi converter I saw two problems: /1/ The newly added form is named Form1 (type TForm1) and this screws up the entire project since these identifiers already exist in the Delphi project. I can circumvent this issue when I close the IDE after conversion and create the new form only after a restart. /2/ But this does not prevent the other issue: The IDE refuses to add the new form to the list of auto-created forms, and therefore a call of "Form2.Show" in the OnClick handler of your button on Form1 must fail. I have no idea what prevents the new form from being auto-created. As a work-around I added the line "Application.CreateForm(TForm2, Form2);" to the project unit manually (and Unit2 to its uses clause). - This way it works. Please file a bug report.

Thanks for your investigation.!

I'll file a bug report tomorrow.

Regards

John Landmesser

Reply by email

John Landmesser
to Werner Pamler: I normally convert Delphi projects manually - it's more work, but I know what's happening…
Werner Pamler wrote 30 lines
Am 24.02.2023 um 21:35 schrieb John Landmesser via lazarus: > Hi, > > I tried to extend an existing and converted? Delphi 7 project by adding > new form to the converted Delphi 7 project. > > But that leads to an AV-error if i try to show this new form by code! I normally convert Delphi projects manually - it's more work, but I know what's happening then... And the manual conversion of your test project worked flawlessly. But anyway: When trying to use the IDE's Delphi converter I saw two problems: /1/ The newly added form is named Form1 (type TForm1) and this screws up the entire project since these identifiers already exist in the Delphi project. I can circumvent this issue when I close the IDE after conversion and create the new form only after a restart. /2/ But this does not prevent the other issue: The IDE refuses to add the new form to the list of auto-created forms, and therefore a call of "Form2.Show" in the OnClick handler of your button on Form1 must fail. I have no idea what prevents the new form from being auto-created. As a work-around I added the line "Application.CreateForm(TForm2, Form2);" to the project unit manually (and Unit2 to its uses clause). - This way it works. Please file a bug report.

Thanks for your investigation.!

I'll file a bug report tomorrow.

Regards

John Landmesser

Reply by email

John Landmesser
to Werner Pamler: I normally convert Delphi projects manually - it's more work, but I know what's happening…
Werner Pamler wrote 30 lines
Am 24.02.2023 um 21:35 schrieb John Landmesser via lazarus: > Hi, > > I tried to extend an existing and converted? Delphi 7 project by adding > new form to the converted Delphi 7 project. > > But that leads to an AV-error if i try to show this new form by code! I normally convert Delphi projects manually - it's more work, but I know what's happening then... And the manual conversion of your test project worked flawlessly. But anyway: When trying to use the IDE's Delphi converter I saw two problems: /1/ The newly added form is named Form1 (type TForm1) and this screws up the entire project since these identifiers already exist in the Delphi project. I can circumvent this issue when I close the IDE after conversion and create the new form only after a restart. /2/ But this does not prevent the other issue: The IDE refuses to add the new form to the list of auto-created forms, and therefore a call of "Form2.Show" in the OnClick handler of your button on Form1 must fail. I have no idea what prevents the new form from being auto-created. As a work-around I added the line "Application.CreateForm(TForm2, Form2);" to the project unit manually (and Unit2 to its uses clause). - This way it works. Please file a bug report.

done!

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40132

Reply by email