I have 2 projects that can run independently. One is built using
Windows Forms Application (.NET) and the other is built on pure C++.
Both project runs fine, but when I try to integrate them, problems
arise. I create new Empty Project, and add the 2 existing project. As
for C++ project, most of the includes and coding is in .CPP file
whereas .H file only contain class definition. As for the form, it is
generated and most of the coding involves event handler is in .H file.
The CPP file contain only _tWinMain function which serves as starting
point of form.
Now, I added a global variable in the Form1.cpp
#include "...CCpp.h"
CCpp *obj;
I then insert this line into the _tWinMain function to create object
obj = new CCpp();
I compile and everything is fine. Now I add a button in Form1.h and
generate a button_click event handler. In the event handler, I try to
use the global pointer obj to call the method in CCpp class
obj->method1();
When I compile again, it gives error 2065 ('obj' undeclared
identifier) and also error C2227 left of '->method1' must point to
class/struct/union.
The bottom line is, I just want to call C++ function from Windows Form
and vice versa (call Windows Form function from C++) but it seems that
integrating the 2 projects doesn't work well.
Please help me. Thank you.