Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Arrays and Enums in an extended control

Arrays and Enums in an extended control

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsc++data-structureshelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    poppabaggins
    wrote on last edited by
    #1

    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 do

    namespace 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

    N 1 Reply Last reply
    0
    • P poppabaggins

      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 do

      namespace 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

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      Since this is managed c++, better ask in this[^] forum

      nave [OpenedFileFinder] [My Blog]

      P 1 Reply Last reply
      0
      • N Naveen

        Since this is managed c++, better ask in this[^] forum

        nave [OpenedFileFinder] [My Blog]

        P Offline
        P Offline
        poppabaggins
        wrote on last edited by
        #3

        Thanks, I'm so new at C++, I wasn't sure which forum to ask in.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups