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

怎樣declare問題視窗按yes時要實行的procedure??

尚未結案
christy315
一般會員


發表:9
回覆:8
積分:3
註冊:2004-07-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-08-01 00:12:45 IP:203.168.xxx.xxx 未訂閱
我想請問,如果我想當出現上圖的視窗時,按yes會出現另一個form~ 要怎樣declare個procedure呢?? 我之前寫了以下語法: procedure Abuttons1Click; begin form2.show; end; procedure ShowHelpDlg; begin str:= 'Welcome to My Crossword Type Puzzle!!!'+chr(10)+chr(13); str:= str+'Do you want to see the instrution of this game first?' +chr(10)+chr(13); MessageDlg(str,mtInformation,mbYesNoCancel,0); Abuttons1Click; end; 但是個program把Abuttons1Click 這個procedure當作普通procedure 而不是click引起的效果~ 當program run時就實行這個procedure,不管click任何東西; 還有一個問題~就是怎樣可以把form1 計算完的integer令另一個form也可以用呢?? thx!!初哥一名~不要見怪
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-08-01 01:30:00 IP:211.76.xxx.xxx 未訂閱
christy315 你好:    因為你沒有檢查MessageDlg(.)的傳回值,所以程式就不管你按了哪個鍵通通會執行Abuttons1Click。 另外對於要讓多個form共用資料,我個人傾向建立一個unit來放置共用的資料或相關的程序。    一個年經的女孩子喜歡設計程式,真是值得鼓勵!也請繼續努力! 附上程式碼請參考。 <>< class="code"> //============================================================== 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 declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses unit2, // for form 2 unit3 // for comA in form3 ; procedure Abuttons1Click; begin form2.show; end; procedure ShowHelpDlg; var str : string; begin str:= 'Welcome to My Crossword Type Puzzle!!!' chr(10) chr(13); str:= str 'Do you want to see the instrution of this game first?' chr(10) chr(13); if ( MessageDlg(str,mtInformation,mbYesNoCancel,0) = mrYes ) then Abuttons1Click; end; procedure TForm1.Button1Click(Sender: TObject); begin ShowHelpDlg; Label1.Caption := IntToStr(comA); end; end. //============================================================== unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} uses unit3; // for comA in unit3. procedure TForm2.Button1Click(Sender: TObject); begin comA := 2; end; end. //============================================================== unit Unit3; interface var comA :integer; implementation end. //============================================================== RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====#####
christy315
一般會員


發表:9
回覆:8
積分:3
註冊:2004-07-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-08-01 17:00:58 IP:203.168.xxx.xxx 未訂閱
THX!!!完全明白了!!! 我會繼續努力的!!!    不過不知為何按yes時會出錯??是因為放在formCreate的procedure嗎?? 出以下的錯誤字句:
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-08-02 16:05:09 IP:211.76.xxx.xxx 未訂閱
christy315 你好: 之所以會出現上述錯誤訊息,確實是將procedure的程式碼放在formCreate中。 但導致真正錯誤的所在是:Abuttons1Click程序中的form2.show;。因為我們在From1 create時,Form2尚未建立,所以這時要叫它秀出來,結果就是看到的錯訊息。 至於如何追蹤這個問題呢? 你只要按F7執行,之後繼續按F7追蹤整個執行過程,就能找到問題點了。
christy315
一般會員


發表:9
回覆:8
積分:3
註冊:2004-07-11

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-08-02 19:57:25 IP:203.168.xxx.xxx 未訂閱
THX!!!~~
系統時間:2024-05-18 15:32:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!