怎樣declare問題視窗按yes時要實行的procedure?? |
尚未結案
|
christy315
一般會員 發表:9 回覆:8 積分:3 註冊:2004-07-11 發送簡訊給我 |
我想請問,如果我想當出現上圖的視窗時,按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 發送簡訊給我 |
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 發送簡訊給我 |
|
richtop
資深會員 發表:122 回覆:646 積分:468 註冊:2003-06-10 發送簡訊給我 |
|
christy315
一般會員 發表:9 回覆:8 積分:3 註冊:2004-07-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |