線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1105
推到 Plurk!
推到 Facebook!

從form自動顯示form2

尚未結案
mo
一般會員


發表:5
回覆:8
積分:2
註冊:2004-08-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-08-31 13:25:47 IP:218.162.xxx.xxx 未訂閱
我是想請問由form1自動延遲幾秒就顯示form2 不必藉由button (是想要顯示"登入畫面錯誤",然後自己延遲幾秒顯示"請再重新登入的新畫面") 請問要如何做呢??謝謝~~
likush
高階會員


發表:5
回覆:235
積分:103
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-08-31 15:32:25 IP:211.23.xxx.xxx 未訂閱
Showmessage('登入畫面錯誤'); Sleep(3000); <--3秒 Showmessage('請再重新登入的新畫面'); ========================= 讀萬卷書~不如來K.TOP走一遭 =========================
change.jian
版主


發表:29
回覆:620
積分:439
註冊:2003-06-02

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-08-31 15:35:25 IP:61.218.xxx.xxx 未訂閱
參考這裡,雖然有點小複雜 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=54788
mo
一般會員


發表:5
回覆:8
積分:2
註冊:2004-08-03

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-09-01 11:07:16 IP:220.130.xxx.xxx 未訂閱
謝謝喔,我有去看了那些參考的資料了,我現在是在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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-09-01 11:56:49 IP:61.218.xxx.xxx 未訂閱
引言: 謝謝喔,我有去看了那些參考的資料了,我現在是在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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-09-01 12:09:36 IP:61.218.xxx.xxx 未訂閱
把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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-09-06 11:39:42 IP:218.162.xxx.xxx 未訂閱
不好意思,因為我把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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-09-06 16:10:12 IP:61.218.xxx.xxx 未訂閱
這裡有個疑問:為何你會在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

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-09-08 14:00:57 IP:218.162.xxx.xxx 未訂閱
你好,謝謝你的回答喔~我已經把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

發送簡訊給我
#10 引用回覆 回覆 發表時間:2004-09-08 15:10:01 IP:61.218.xxx.xxx 未訂閱
我想應該在你的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

發送簡訊給我
#11 引用回覆 回覆 發表時間:2004-09-13 10:21:45 IP:203.204.xxx.xxx 未訂閱
我之前試過在OnTimer的程式碼中把Timer disable了,但是還是會有同樣的情形發生,所以不知道是哪裡出了錯誤…我已經把程式上傳到那個連結了,謝謝回答喔~
mo
一般會員


發表:5
回覆:8
積分:2
註冊:2004-08-03

發送簡訊給我
#12 引用回覆 回覆 發表時間:2004-09-13 10:37:52 IP:218.162.xxx.xxx 未訂閱
謝謝你的回答喔,我後來發現因為我沒在Project->Options->Forms中將任何Form由Auto-create forms移動到Available forms裡,所以 procedure Timer1Timer(Sender: TObject); private { Private declarations } Form4:TForm4;///////////////////這行等於是多餘的?? public { Public declarations } end; 將它刪除後就可以只顯示一個form4,應該是這個錯誤吧,真是麻煩你啦~謝謝~~
系統時間:2024-05-17 11:21:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!