[問題] C++/Cli WindosForm的互相呼叫

看板C_and_CPP作者 (呵呵呵)時間10年前 (2014/01/09 20:09), 編輯推噓1(104)
留言5則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) C++/CLI 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) nope 問題(Question): 我想寫一個程式 一開始會有一個視窗出來 按下OK之後跳出另一個視窗 原本的視窗就關閉 另外一個視窗的menu有一個按下去就呼叫第一個視窗 餵入的資料(Input): 預期的正確結果(Expected Output): 如同上面寫的 兩個視窗互相呼叫 一個出來另一個消失 錯誤結果(Wrong Output): 第一個視窗按下OK之後跳出第二個視窗 但是第一個視窗卻沒消失 第二個視窗寫好之後卻不能跑 有什麼方法可以解決這種情況嗎? 程式碼(Code):(請善用置底文網頁, 記得排版) //第一個視窗 private: System::Void levelChooseButton_Click (System::Object^ sender, System::EventArgs^e) { this->Close(); Tower form; form.ShowDialog(); } //第二個視窗 private: System::Void levelToolStripMenuItem_Click (System::Object^ sender, System::EventArgs^ e) { this->Close(); levelScelect form; form.ShowDialog(); } 補充說明(Supplement): 該 include 的 header 我都有 include namespace也沒有用錯 補充 試過 Hide 也不行 -- 我喜歡coding,但我不喜換debug 我不想當個debug guy -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.241.34.184 ※ 編輯: jack710619 來自: 123.241.34.184 (01/09 20:12)

01/09 20:38, , 1F
Tower form; ...... gcnew
01/09 20:38, 1F
gcnew?為何要genew? ※ 編輯: jack710619 來自: 123.241.34.184 (01/09 20:45)

01/10 00:58, , 2F
一樓少了^嗎
01/10 00:58, 2F

01/10 03:28, , 3F
並沒有,給他點提示而已
01/10 03:28, 3F

01/10 05:57, , 4F
爸爸生兩個小孩,爸爸沒沒窗戶。
01/10 05:57, 4F

01/10 06:20, , 5F
後來問了朋友,結果發生更神奇的問題,晚點再處理 :p
01/10 06:20, 5F
後來改成 //第一個視窗 ref class levelScelect; public class Tower : public System::Windows::Forms::Form { ... private: System::Void levelChooseButton_Click (System::Object^ sender, System::EventArgs^e) { this->Close(); Tower^ form=gcnew Tower; form->ShowDialog(); } } //第二個視窗 ref class Tower; public class levelScelect : public System::Windows::Forms::Form { private: System::Void levelToolStripMenuItem_Click (System::Object^ sender, System::EventArgs^ e { this->Close(); levelScelect^ form=gcnew levelScelect; form->ShowDialog(); } } 結果兩個form的設計頁面裡面的東西就互換了@@ 附上目前的"完整"程式 因為是form我不曉得要怎麼貼上來...... http://goo.gl/6Njs0r ※ 編輯: jack710619 來自: 123.241.34.184 (01/10 13:53)
文章代碼(AID): #1Ipf5XmO (C_and_CPP)