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. Delclaring a static array for use with CImage List!

Delclaring a static array for use with CImage List!

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestionlearning
2 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.
  • A Offline
    A Offline
    adonisv
    wrote on last edited by
    #1

    :confused:I have a tree control class. I also have an image list that I want to associate with my tree. Why can't I declare a static array and initialize it with the id's of icons, in the resource file, in my tree control class?? :mad: I've included "resource.h" so I should know what the IDI's are... class RCanalTree : public CTreeCtrl { // Construction public: RCanalTree(CCanalManager *pCanalManager=NULL); // Attributes public: const CCanalManager* GetCanalManagerPointer() { return m_pCanalManager; } bool SetCanalManagerPointer(CCanalManager *pCanalManager); // Operations public: static int m_icons[]={ IDI_ICON_SYSTEM, IDI_ICON_CANAL, IDI_ICON_SITE, IDI_ICON_WELL, IDI_ICON_TURNOUT, IDI_ICON_PUMP, 0 // NULL place holder used to terminate the array. }; virtual void Populate(); int DeleteChildren(HTREEITEM hParent); HTREEITEM GetDepthNextItem(HTREEITEM hItem); HTREEITEM FindItem(const char *name, int dwData); HTREEITEM InsertChildItem(const char *name, int dImage, HTREEITEM hParent, DWORD data, int iCheck=-1, bool bCondition=true); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(RCanalTree) //}}AFX_VIRTUAL // Implementation public: bool InitializeImageList(); int GetImageIndexFor(int idOfIcon); bool DeleteChildItem(HTREEITEM hParent, const char* name, DWORD data); virtual void UpdateImages(); virtual EnumForOnCheck OnCheck(HTREEITEM hItem, bool bNowChecked); int GetIconIndex(int idOfIcon); virtual ~RCanalTree(); // Generated message map functions protected: bool IsScheduleLocked(); CCanalManager* m_pCanalManager; CImageList *pImageList; //{{AFX_MSG(RCanalTree) afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; baaaah!

    J 1 Reply Last reply
    0
    • A adonisv

      :confused:I have a tree control class. I also have an image list that I want to associate with my tree. Why can't I declare a static array and initialize it with the id's of icons, in the resource file, in my tree control class?? :mad: I've included "resource.h" so I should know what the IDI's are... class RCanalTree : public CTreeCtrl { // Construction public: RCanalTree(CCanalManager *pCanalManager=NULL); // Attributes public: const CCanalManager* GetCanalManagerPointer() { return m_pCanalManager; } bool SetCanalManagerPointer(CCanalManager *pCanalManager); // Operations public: static int m_icons[]={ IDI_ICON_SYSTEM, IDI_ICON_CANAL, IDI_ICON_SITE, IDI_ICON_WELL, IDI_ICON_TURNOUT, IDI_ICON_PUMP, 0 // NULL place holder used to terminate the array. }; virtual void Populate(); int DeleteChildren(HTREEITEM hParent); HTREEITEM GetDepthNextItem(HTREEITEM hItem); HTREEITEM FindItem(const char *name, int dwData); HTREEITEM InsertChildItem(const char *name, int dImage, HTREEITEM hParent, DWORD data, int iCheck=-1, bool bCondition=true); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(RCanalTree) //}}AFX_VIRTUAL // Implementation public: bool InitializeImageList(); int GetImageIndexFor(int idOfIcon); bool DeleteChildItem(HTREEITEM hParent, const char* name, DWORD data); virtual void UpdateImages(); virtual EnumForOnCheck OnCheck(HTREEITEM hItem, bool bNowChecked); int GetIconIndex(int idOfIcon); virtual ~RCanalTree(); // Generated message map functions protected: bool IsScheduleLocked(); CCanalManager* m_pCanalManager; CImageList *pImageList; //{{AFX_MSG(RCanalTree) afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; baaaah!

      J Offline
      J Offline
      Jambolo
      wrote on last edited by
      #2

      Read up on how to use static member variables. Initialize it outside of the declaration like this:

      class RCanalTree : public CTreeCtrl
      {
      ...
      static int m_icons[];
      ...
      };

      ...
      

      int RCanalTree::m_icons[]={
      IDI_ICON_SYSTEM,
      IDI_ICON_CANAL,
      IDI_ICON_SITE,
      IDI_ICON_WELL,
      IDI_ICON_TURNOUT,
      IDI_ICON_PUMP,
      0 // NULL place holder used to terminate the array.
      };

      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