|
-
March 11th, 2010, 04:33 AM
#1
linking two .h file
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
Code:
//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
Code:
#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.
-
March 11th, 2010, 01:58 PM
#2
Re: linking two .h file
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
If my help was useful, please rate my posting. Thanks! 
-
March 14th, 2010, 08:43 AM
#3
Re: linking two .h file
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|