從form自動顯示form2 |
尚未結案
|
mo
一般會員 發表:5 回覆:8 積分:2 註冊:2004-08-03 發送簡訊給我 |
|
likush
高階會員 發表:5 回覆:235 積分:103 註冊:2002-10-08 發送簡訊給我 |
|
change.jian
版主 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
|
mo
一般會員 發表:5 回覆:8 積分:2 註冊:2004-08-03 發送簡訊給我 |
謝謝喔,我有去看了那些參考的資料了,我現在是在form1加入一個TTimer,並且在Project->Options->Forms中將Form2由Auto-create forms移動到Available forms,然後在File->Use Unit..中加入Unit2,以下是程式碼,但是還是有錯誤訊息,不知道該如何修改… unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, System.ComponentModel, Borland.Vcl.ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
Form2 : TForm2;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.nfm} procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Form2 = nil then
Form2 := TForm2.Create(Self);
From2.Show;
end;
end. 以下是錯誤訊息:
[Warning] Project1.dpr(17): Unit 'Borland.Vcl.Forms' is specific to a platform
[Warning] Unit1.pas(6): Unit 'Borland.Vcl.Windows' is specific to a platform
[Warning] Unit1.pas(6): Unit 'Borland.Vcl.Messages' is specific to a platform
[Warning] Unit1.pas(6): Unit 'Borland.Vcl.Graphics' is specific to a platform
[Warning] Unit1.pas(6): Unit 'Borland.Vcl.Controls' is specific to a platform
[Warning] Unit1.pas(6): Unit 'Borland.Vcl.Forms' is specific to a platform
[Warning] Unit1.pas(7): Unit 'Borland.Vcl.Dialogs' is specific to a platform
[Warning] Unit1.pas(7): Unit 'Borland.Vcl.ExtCtrls' is specific to a platform
[Error] Unit1.pas(15): Undeclared identifier: 'TForm2'
[Warning] Unit2.pas(6): Unit 'Borland.Vcl.Windows' is specific to a platform
[Warning] Unit2.pas(6): Unit 'Borland.Vcl.Graphics' is specific to a platform
[Warning] Unit2.pas(6): Unit 'Borland.Vcl.Forms' is specific to a platform
[Warning] Unit2.pas(7): Unit 'Borland.Vcl.Dialogs' is specific to a platform
[Fatal Error] Unit1.pas(25): Could not compile used unit 'Unit2.pas'
|
T.J.B
版主 發表:29 回覆:532 積分:497 註冊:2002-08-14 發送簡訊給我 |
引言: 謝謝喔,我有去看了那些參考的資料了,我現在是在form1加入一個TTimer,並且在Project->Options->Forms中將Form2由Auto-create forms移動到Available forms,然後在File->Use Unit..中加入Unit2,以下是程式碼,但是還是有錯誤訊息,不知道該如何修改… unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, System.ComponentModel, Borland.Vcl.ExtCtrls; type TForm1 = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private { Private declarations } Form2 : TForm2; public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.nfm} procedure TForm1.Timer1Timer(Sender: TObject); begin if Form2 = nil then Form2 := TForm2.Create(Self); From2.Show;<-----打錯字了 end; end. 以下是錯誤訊息: [Warning] Project1.dpr(17): Unit 'Borland.Vcl.Forms' is specific to a platform [Warning] Unit1.pas(6): Unit 'Borland.Vcl.Windows' is specific to a platform [Warning] Unit1.pas(6): Unit 'Borland.Vcl.Messages' is specific to a platform [Warning] Unit1.pas(6): Unit 'Borland.Vcl.Graphics' is specific to a platform [Warning] Unit1.pas(6): Unit 'Borland.Vcl.Controls' is specific to a platform [Warning] Unit1.pas(6): Unit 'Borland.Vcl.Forms' is specific to a platform [Warning] Unit1.pas(7): Unit 'Borland.Vcl.Dialogs' is specific to a platform [Warning] Unit1.pas(7): Unit 'Borland.Vcl.ExtCtrls' is specific to a platform [Error] Unit1.pas(15): Undeclared identifier: 'TForm2' [Warning] Unit2.pas(6): Unit 'Borland.Vcl.Windows' is specific to a platform [Warning] Unit2.pas(6): Unit 'Borland.Vcl.Graphics' is specific to a platform [Warning] Unit2.pas(6): Unit 'Borland.Vcl.Forms' is specific to a platform [Warning] Unit2.pas(7): Unit 'Borland.Vcl.Dialogs' is specific to a platform [Fatal Error] Unit1.pas(25): Could not compile used unit 'Unit2.pas'天行健 君子當自強不息~~@.@
------
天行健 君子當自強不息~~@.@ |
change.jian
版主 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
把implementation後面的uses Unit2移到上面的uses裡
引言: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, System.ComponentModel, Borland.Vcl.ExtCtrls; type TForm1 = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private { Private declarations } Form2 : TForm2; <--這裡已經有用到TForm2了,但上方的uses裡沒有TForm2的宣告 public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.nfm} procedure TForm1.Timer1Timer(Sender: TObject); begin if Form2 = nil then Form2 := TForm2.Create(Self); From2.Show; end; end. 以下是錯誤訊息: ... [Error] Unit1.pas(15): Undeclared identifier: 'TForm2' ... |
mo
一般會員 發表:5 回覆:8 積分:2 註冊:2004-08-03 發送簡訊給我 |
不好意思,因為我把implementation後面的uses Unit2移到上面的uses裡了,但是是不是因為呼叫的問題而產生了這個錯誤(以下程式碼做"/"記號的那一行),如果是的話請問該如何解決呢,謝謝~ [Error] Unit1.pas(31): Cannot call constructors using instance variables
[Fatal Error] Project2.dpr(17): Could not compile used unit 'Unit1.pas' unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, System.ComponentModel, Borland.Vcl.ExtCtrls, Unit2; type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
TForm2: TForm2;
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.nfm} procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Form2 = nil then
Form2 := TForm2.Create(Self);////////////////////////////////////
Form2.Show; end; end.
|
change.jian
版主 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
這裡有個疑問:為何你會在TForm1裡放Timer呢?我的Timer是放在waitForm裡,也就是要Show message的form裡.會用Timer的原因,是為了要把form create與form show的程式區隔開來.
而且你的程式裡,Timer的程式第一行應該就是把Timer本身disable,不然又會再觸發一次,程式就會出錯了.
引言: 不好意思,因為我把implementation後面的uses Unit2移到上面的uses裡了,但是是不是因為呼叫的問題而產生了這個錯誤(以下程式碼做"/"記號的那一行),如果是的話請問該如何解決呢,謝謝~ [Error] Unit1.pas(31): Cannot call constructors using instance variables [Fatal Error] Project2.dpr(17): Could not compile used unit 'Unit1.pas' unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, System.ComponentModel, Borland.Vcl.ExtCtrls, Unit2; type TForm1 = class(TForm) Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private { Private declarations } TForm2: TForm2; //<---這一行錯了,應該為Form2:TForm2 public { Public declarations } end; var Form1: TForm1; implementation {$R *.nfm} procedure TForm1.Timer1Timer(Sender: TObject); begin if Form2 = nil then Form2 := TForm2.Create(Self);//////////////////////////////////// Form2.Show; end; end. |
mo
一般會員 發表:5 回覆:8 積分:2 註冊:2004-08-03 發送簡訊給我 |
你好,謝謝你的回答喔~我已經把Timer改放在waitForm裡,也就是現在的form4裡.可以達成先顯示form3再顯示form4的功能,但是會造成一個問題就是會不停的顯示好幾個form4的視窗(我在Project->Options->Forms中沒將任何Form由Auto-create forms移動到Available forms裡)
請問是哪個地方出了問題呢,謝謝~ unit Unit4; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, System.ComponentModel, Borland.Vcl.ExtCtrls; type
TForm4 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
Form4:TForm4; public
{ Public declarations }
end; var
Form4: TForm4; implementation uses Unit3; {$R *.nfm} procedure TForm4.Timer1Timer(Sender: TObject);
begin
if Form4 = nil then
Form4 := TForm4.Create(Self);
Form4.Show; end; end.
|
change.jian
版主 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
我想應該在你的form3的程式有問題,你要不要把你的程式整個上傳到這裡 http://delphi.ktop.com.tw/forum.asp?FORUM_ID=97 對了,這裡要改成這樣
procedure TForm4.Timer1Timer(Sender: TObject); begin Timer1.Enabled:=False; //這樣就不會一直出現了 if Form4 = nil then Form4 := TForm4.Create(Self); Form4.Show; end;發表人 - change.jian 於 2004/09/08 15:17:28 |
mo
一般會員 發表:5 回覆:8 積分:2 註冊:2004-08-03 發送簡訊給我 |
|
mo
一般會員 發表:5 回覆:8 積分:2 註冊:2004-08-03 發送簡訊給我 |
謝謝你的回答喔,我後來發現因為我沒在Project->Options->Forms中將任何Form由Auto-create forms移動到Available forms裡,所以 procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
Form4:TForm4;///////////////////這行等於是多餘的?? public
{ Public declarations }
end; 將它刪除後就可以只顯示一個form4,應該是這個錯誤吧,真是麻煩你啦~謝謝~~
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |