473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to declare a Class in C++ window form application?

Hi,


May I know how to declare a Class in C++ window application form? Below is my code and error as shown below as well.

here is my class declaration:

ref class CLoadObj {

public:


bool ImportObj(t3DModel *pModel, char *strFileName);


System::Void ReadObjFile(t3DModel *pModel);

System::Void ReadVertexInfo(System::Void);

System::Void ReadFaceInfo(System::Void);

System::Void FillInObjectInfo(t3DModel *pModel);

System::Void ComputeNormals(t3DModel *pModel);

System::Void SetObjectMaterial(t3DModel *pModel, int whichObject, int materialID);

private:

FILE *m_FilePointer;

vector<CVector3> m_pVertices;

vector<tFace> m_pFaces;

vector<CVector2> m_pTextureCoords;

bool m_bObjectHasUV;

bool m_bJustReadAFace;
};


#endif

Below is my declaration a Class in window form application, and the error was stated as below:

CLoadObj^ g_LoadObj = gcnew CLoadObj;


error when debugging:

1>d:\fyp\a3203s\ver2of opengl_on_a_windows_form\opengl_on_a_windows_form\ OpenGL.h(17) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'

I would like to use the g_LoadObj to replace the CLoadObj but Im unable to link to the specify class by using the g_LoadObj.

I had tried another method to declare:

CLoadObj* g_LoadObj = gcnew CLoadObj;
and the errors occured when debugging was as below:

1>d:\fyp\a3203s\ver2of opengl_on_a_windows_form\opengl_on_a_windows_form\ OpenGL.h(17) : error C3699: '*' : cannot use this indirection on type 'CLoadObj'
1> compiler replacing '*' with '^' to continue parsing
1>d:\fyp\a3203s\ver2of opengl_on_a_windows_form\opengl_on_a_windows_form\ OpenGL.h(17) : error C3145: 'g_LoadObj' : global or static variable may not have managed type 'CLoadObj ^'
1> may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap


Im unable to replace the class name by using the g_LoadObj. Im using window form application is it the syntax will be different from C++?
Oct 12 '08 #1
1 3866
Banfa
9,065 Expert Mod 8TB
Have you tried

CLoadObj g_LoadObj;

?
Oct 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: agrsaurabh | last post by:
Hello Everybody, I have created an AVI Player using DirectShow. This player is working fine. I have also created a View Window (with class name CViewWnd) using CFrameWnd class. This view...
4
by: fake | last post by:
What exactly does the line: rGfxOptionsWnd* m_pGfxOptionsWnd; do? I have chased this bug and narrowed it down to something that I believe should not happen and I don't even know what could...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
8
by: Mészáros Tamás | last post by:
Hi all, how can I set an app's main window to visible from an other application? My problem is, that I know only the handle of the other app's main process, because the application's main window...
0
by: Tom | last post by:
Here is a very strange problem that I am stumped by. I have a rather large application written in VB.NET (of course) using Framework 1.1. As you know, with an MDI application you can have multiple...
38
by: JTL | last post by:
I have learnt java before and now begin to learn c++ what puzzle me is that seem that different SDKs(c++builder, vs.net, gcc..) has its own class library we know that in java there are only one...
1
by: bytebugs | last post by:
Hi, As a matter of principle I have refranied from creating an instance of Form or UserControl from within a class that does not inherit from System.Windows.Form. I am looking for comments on...
5
by: Sin Jeong-hun | last post by:
class Engine { Thread Worker; public event ... EngineMessage; public void Start() { Worker=new Thread(new ThreadStart(Run)); Worker.Start(); } private Run()
3
by: Andy | last post by:
So, I'm playing around with VB and tries to get the hang things. When I add a form to my application, and I begin to add code to the form, it stars with " Public Class form1" But is Form1 a class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.