J
Jacek
Hello
I'm very newbie in programing and first time try move function to header
file.
I have simple function declered on Form1.h
void Status (String ^message){
this->richTextBox1->AppendText(message+"\n");
this->richTextBox1->ScrollToCaret(); }
it's work good on this form i.e on event button.click :
Status ("Hello world");
I'd like move this function to header file function.h and function.cpp
In file function.h are declaration like this:
#pragma once
void Status (System::String ^message);
In file function.cpp I added body of the function:
#include "function.h"
#include "stdafx.h"
void Status (System::String ^message){
this->richTextBox1-> AppendText(message+"\n");
this->richTextBox1-> ScrollToCaret();
};
Unfortunately it doesn't work. I lost a lot of time to resolve error but
without result.
I don't know how replace pointer this->
Error from VC++:
..\function.cpp(11) : error C2673: 'Status' : global functions do not have
'this' pointers
..\function.cpp(11) : error C2227: left of '->richTextBox1' must point to
class/struct/union/generic type
..\function.cpp(11) : error C2227: left of '->AppendText' must point to
class/struct/union/generic type
..\function.cpp(12) : error C2673: 'Status' : global functions do not have
'this' pointers
..\function.cpp(12) : error C2227: left of '->richTextBox1' must point to
class/struct/union/generic type
..\function.cpp(12) : error C2227: left of '->ScrollToCaret' must point to
class/struct/union/generic type
Where I made error ? Please help.
I'm very newbie in programing and first time try move function to header
file.
I have simple function declered on Form1.h
void Status (String ^message){
this->richTextBox1->AppendText(message+"\n");
this->richTextBox1->ScrollToCaret(); }
it's work good on this form i.e on event button.click :
Status ("Hello world");
I'd like move this function to header file function.h and function.cpp
In file function.h are declaration like this:
#pragma once
void Status (System::String ^message);
In file function.cpp I added body of the function:
#include "function.h"
#include "stdafx.h"
void Status (System::String ^message){
this->richTextBox1-> AppendText(message+"\n");
this->richTextBox1-> ScrollToCaret();
};
Unfortunately it doesn't work. I lost a lot of time to resolve error but
without result.
I don't know how replace pointer this->
Error from VC++:
..\function.cpp(11) : error C2673: 'Status' : global functions do not have
'this' pointers
..\function.cpp(11) : error C2227: left of '->richTextBox1' must point to
class/struct/union/generic type
..\function.cpp(11) : error C2227: left of '->AppendText' must point to
class/struct/union/generic type
..\function.cpp(12) : error C2673: 'Status' : global functions do not have
'this' pointers
..\function.cpp(12) : error C2227: left of '->richTextBox1' must point to
class/struct/union/generic type
..\function.cpp(12) : error C2227: left of '->ScrollToCaret' must point to
class/struct/union/generic type
Where I made error ? Please help.