Hi All,
You'll have to excuse me because I'm coming from a more traditional C/C++ background (like a WIN32 project with a standard WndProc), and I've just started learning about Windows Forms. I have created a windows form project in visual studio so that I can use a windows form to interact with the game class that I'm creating, but I'm running into some problems.
For one thing, I would like to be able to call Image::FromFile() one time only during initialization, and store the result in a member variable (called mBGImage). From what I can tell, the variable needs to be of type String^ (this caret symbol is new to me, but I understand it is the "managed code" version of the standard pointer, which would look like String*). When I try to compile the following code (located in my header file) I get the error "error C3265: cannot declare a managed 'mBGImage' in an unmanaged 'BSG::BSGame'".
What am I doing wrong and how can I store the result of Image::FromFile() permanently in my class?
Oh, and also, when I try to declare a global variable of type "Image^", I get "error C3145: global or static variable may not have managed type System::Drawing::Image ^"
----------------------------
#include "stdafx.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace BSG
{
const Point kGridSize(400, 400); //size of grid (width, height)
const Point kGridTiles(10, 10); //total number of tiles (x,y)
public class BSGame
{
public:
BSGame(void); //constructor
~BSGame(void); //destructor
void Init(void); //Initialize the game
void DrawScreen(Graphics^ gfxObj, Rectangle rect);
private:
bool mInited; //is this object initialized?
Image^ mBGImage;
};
}
You'll have to excuse me because I'm coming from a more traditional C/C++ background (like a WIN32 project with a standard WndProc), and I've just started learning about Windows Forms. I have created a windows form project in visual studio so that I can use a windows form to interact with the game class that I'm creating, but I'm running into some problems.
For one thing, I would like to be able to call Image::FromFile() one time only during initialization, and store the result in a member variable (called mBGImage). From what I can tell, the variable needs to be of type String^ (this caret symbol is new to me, but I understand it is the "managed code" version of the standard pointer, which would look like String*). When I try to compile the following code (located in my header file) I get the error "error C3265: cannot declare a managed 'mBGImage' in an unmanaged 'BSG::BSGame'".
What am I doing wrong and how can I store the result of Image::FromFile() permanently in my class?
Oh, and also, when I try to declare a global variable of type "Image^", I get "error C3145: global or static variable may not have managed type System::Drawing::Image ^"
----------------------------
#include "stdafx.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace BSG
{
const Point kGridSize(400, 400); //size of grid (width, height)
const Point kGridTiles(10, 10); //total number of tiles (x,y)
public class BSGame
{
public:
BSGame(void); //constructor
~BSGame(void); //destructor
void Init(void); //Initialize the game
void DrawScreen(Graphics^ gfxObj, Rectangle rect);
private:
bool mInited; //is this object initialized?
Image^ mBGImage;
};
}