Hi,
how I can access controls of Form class from another simple class
Lets say I have create new clr (c++ .net 2008) windows application, & add a lable1 on it, (Form1.cpp & Form1.h created by default having namaspace tmp_beginInvoke_c)
then I create a new b.h file & add a simple reference class b. like code below,
#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;
};
}
I also add following in Form1.h
- #include "b.h"
- using namespace tmp_beginInvoke_c_B;
- b^ obj = gcnew b(); // this line in constructure.
raising build error :-(
My target:- I want to pass reference of Form1 created instance to all b class object, b class object will call a function of form1 class randomly on event base.
if I say ore accuretely b class object will call beginInvoke of control on Form1.
something like
Thread^ t = gcnew Thread(gcnew ThreadStart((frm,&tmp_beginInvoke_c::Form1::ChangeLabel)); //which will call beginInvike of control