Click to See Complete Forum and Search --> : linking two .h file


zole_ria9
March 11th, 2010, 03:33 AM
How would you call a label (or panel, or etc) and then change its properties from another .h file?

Here's my code (snippet):
Form1.h

//let's assume that panel3 is already declared and there are no problem with it
#include "LinesDraw.h";
public ref class Form1 : public System::Windows::Forms::Form {
public: System::Windows::Forms::Label^ sample;
void InitializeComponent(void){
this->sample = (gcnew System::Windows::Forms::Label());
this->panel3->Controls->Add(this->sample);
}
}


LinesDraw.h

#include "Form1.h"
public class LinesDraw{
public:
//constructors and destructors here
void hello(){
Form1 f;
//here I tried putting f.sample; but it isn't working
//any idea on how I will call sample?
//and also how would I change its Text Property?
//is something like this ok?
//f.sample ->Text = L"Sample"
}
};


I want to call sample since I want to change its properties.
For example changing its Text property.
And also. this is just for curiosity but why is there an L in changing/declaring Text and Name property before the name itself?

Also, Form1.h is a managed form while LinesDraw.h is an unmanaged.
I wonder if its ok?? And if it is, how would I call a managed class using unmanaged class?

Any help would be appreciated.

jalway
March 11th, 2010, 12:58 PM
What you're doing does compile. What exactly is the problem?

Btw, if you want to change the properties of control within the form, it might be better to add a function or property through which to do it.

The "L" is for wide characters. Here is a video lesson on the subject:

http://xoax.net/comp/cpp/console/Lesson45.php

zole_ria9
March 14th, 2010, 08:43 AM
it says that you cannot call a function from a unmanaged class using a managed file and vice versa.
And sorry for a late reply.
I will read and watch the resources that you've given me.
And thanks! :)