0
我怎麼可以從另一個簡單的類班上課的訪問,從裁判類GUI類
比方說 我已創建新的CLR(C++ .NET 2008)的Windows應用程序訪問Form
類的控件,&添加(Form1.cpp & Form1.h默認創建爲namaspace tmp_beginInvoke_c
)
然後我創建一個新的bh文件&添加一個簡單的引用類b。如下面的代碼,
#include "Form1.h" namespace tmp_beginInvoke_c_B { //using namespace tmp_beginInvoke_c; //{error C2871: 'tmp_beginInvoke_c' : a namespace with this name does not exist,} namespace of Form1 in my project using namespace System; using namespace System::ComponentModel; public ref class b { public: b(void) { } b(Form1^% guiForm) { //guiForm->ChangeLabel(); //this->frm = gcnew Form1(); this->frm = guiForm; this->frm->ChangeLabel(); } int i; Form1 ^frm; }; }
我還添加以下的Form1.h
#include "b.h"
using namespace tmp_beginInvoke_c_B;
b^ obj = gcnew b(); // this line in constructure
。
提高建立自己的錯誤:-(
我的目標: - 我想傳遞給所有b
類對象Form1
創建的實例的引用, b
類對象將隨機調用Form1
類的函數事件基地。
,如果我說的礦石accuretely b類對象將呼叫控制的beginInvoke
上Form1
。
像
Thread^ t = gcnew Thread(gcnew ThreadStart((frm,&tmp_beginInvoke_c::Form1::ChangeLabel)); //which will call beginInvike of control
重新格式化,以便我們可以閱讀它。如果您對我們的幫助很輕鬆,我們將很樂意爲您提供幫助。 – Rap 2009-10-09 12:55:19