![]() |
AW: Probleme beim Zugreifen auf 2. Form
Zitat:
|
AW: Probleme beim Zugreifen auf 2. Form
Ich hab's eben nochmal mit einem neuen Projekt probiert und entweder ist mein Lazarus verbuggt oder ich mache was falsch:
Neues Projekt erstellt - 2 Formulare - Zweites Formular in's erste eingebunden - Button und Labels darauf platziert und gleiches Problem: tut sich nix
Delphi-Quellcode:
unit Unit1;
{$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Unit2; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin Form2.Label1.Caption := 'Form2'; Label1.Caption := 'Form1'; end; procedure TForm1.FormCreate(Sender: TObject); begin Form2 := TForm2.Create(self); Form2.Show; end; end.
Delphi-Quellcode:
Irgendwas muss ich doch falsch gemacht haben :?
unit Unit2;
{$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm2 } TForm2 = class(TForm) Label1: TLabel; private { private declarations } public { public declarations } end; var Form2: TForm2; implementation {$R *.lfm} end. |
AW: Probleme beim Zugreifen auf 2. Form
Wo ist das Problem:
Delphi-Quellcode:
funktioniert!
program Project2;
uses Forms, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.CreateForm(TForm2, Form2); Application.Run; end. (* *************************************** *) unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; procedure Button1Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin label1.Caption:='Labello1'; form2.label1.Caption:='labello2'; form2.show; end; end. (* ********************************************************* *) unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Label1: TLabel; private { Private-Deklarationen } public { Public-Deklarationen } end; var Form2: TForm2; implementation {$R *.dfm} end. Gruß K-H |
AW: Probleme beim Zugreifen auf 2. Form
Liste der Anhänge anzeigen (Anzahl: 1)
Jetzt bin ich komplett verwirrt o.O
Wär nett wenn jemand das hier ausprobieren könnte. Falls es an meiner Lazarus-Version liegt (die ich übrigens eben gepatcht hab), sollten sich beide Labels ändern... |
AW: Probleme beim Zugreifen auf 2. Form
Zitat:
|
AW: Probleme beim Zugreifen auf 2. Form
Zitat:
|
AW: Probleme beim Zugreifen auf 2. Form
Welche Fehlermeldung und in welcher Zeile taucht die auf (gesamte Methode bis dahin posten)
|
AW: Probleme beim Zugreifen auf 2. Form
Zitat:
Wie sieht denn die Projektdatei aus? |
AW: Probleme beim Zugreifen auf 2. Form
Zitat:
Bei Adresse 41B771" Dann zeigt er mir ne Stelle in 'nem Assembler-Fenster an, wobei ich aber nicht sehr viel damit anfangen kann. Ich kann ja trotzdem einfach mal die Zeile zitieren:
Code:
Sieht ja für mich einfach aus, dass er da auf ne Form zugreifen will, die nicht vorhanden ist... aber ich halt mich da lieber raus :D
(FORMS_TCUSTOMFORM_$__SHOW (19)<- Zeile im Assembler)
0041B771 8b09 mov (%ecx),%ecx Edit: @Olli: Das ist ja mal eine interessante These! :D
Delphi-Quellcode:
Jetzt merk ich's auch... Form2 sollte ja eigentlich schon erstellt sein. Aber müsste es dann nicht ein Namenskonflikt geben?
program project1;
{$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Interfaces, Forms,Unit1, Unit2; {$R *.res} begin Application.Initialize; RequireDerivedFormResource := True; Application.CreateForm(TForm1, Form1); Application.CreateForm(TForm2, Form2); Application.Run; end. Edit2: JAAA! :D Es muss wirklich so gewesen sein. Ich hab jetzt nen Button eingefügt, der die andere Form erstellt und es funktioniert endlich! Vielen Dank für die Hilfe! :thumb: |
AW: Probleme beim Zugreifen auf 2. Form
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz