Arrays and Enums in an extended control
-
Hi, I'm completely new to C++ as a whole, so there might be a simple answer to my question, so here goes. I'm trying to write a program that will have the screen broken up into zones, or areas, each with a Point (location) a Size, an Image, and an array of terrain types (an enum). Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this, I tried extending the PictureBox control, but this has given me even more headaches. Basically, I can't figure out how to declare/use an array in an extended control.
#pragma once
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace cli; //something I think MSDN said I had to donamespace MapEdit
{
//better than a "magic number". there can only be 3 different types of terrain per square
//used in the TerrainTypes array
const int MAX_TERRAIN = 3;public ref class Zone : public System::Windows::Forms::PictureBox { public: enum Terrain //says I can't mix types { Plain, Hill, Wood, Marsh, Stream, River, ShoreLine, Impassable }; array<byte^> ^TerrainTypes; //this doesn't work int TerrainTypes\[3\]; //neither does this.
...
All of my errors (except the parts where I try to use these faulty enum/ array) come from this block. Frankly, I'm at a loss as to how to fix this. Also, if someone could tell me how to include a Bitmap in an unmanged class, that would be nice too. Thanks, Christian
-
Hi, I'm completely new to C++ as a whole, so there might be a simple answer to my question, so here goes. I'm trying to write a program that will have the screen broken up into zones, or areas, each with a Point (location) a Size, an Image, and an array of terrain types (an enum). Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this, I tried extending the PictureBox control, but this has given me even more headaches. Basically, I can't figure out how to declare/use an array in an extended control.
#pragma once
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace cli; //something I think MSDN said I had to donamespace MapEdit
{
//better than a "magic number". there can only be 3 different types of terrain per square
//used in the TerrainTypes array
const int MAX_TERRAIN = 3;public ref class Zone : public System::Windows::Forms::PictureBox { public: enum Terrain //says I can't mix types { Plain, Hill, Wood, Marsh, Stream, River, ShoreLine, Impassable }; array<byte^> ^TerrainTypes; //this doesn't work int TerrainTypes\[3\]; //neither does this.
...
All of my errors (except the parts where I try to use these faulty enum/ array) come from this block. Frankly, I'm at a loss as to how to fix this. Also, if someone could tell me how to include a Bitmap in an unmanged class, that would be nice too. Thanks, Christian
-
Thanks, I'm so new at C++, I wasn't sure which forum to ask in.