c++ - Member Variables - Undefined and Inaccessible -


i not able access private member variables member function caboutdlg::onlbuttondown. when attempted assign new value ellipsecolor undeclared identifier error. when try access through class ccsit861a3vasilkovskiydlg::ellipsecolorthe compiler says inaccessible.

what have missed, , how can access/modify these variable?

header file:

#pragma once   // ccsit861a3vasilkovskiydlg dialog class ccsit861a3vasilkovskiydlg : public cdialogex { // construction public:     ccsit861a3vasilkovskiydlg(cwnd* pparent = null);    // standard constructor  // dialog data     enum { idd = idd_csit861a3vasilkovskiy_dialog };      protected:     virtual void dodataexchange(cdataexchange* pdx);    // ddx/ddv support   // implementation protected:     hicon m_hicon;      // generated message map functions     virtual bool oninitdialog();     afx_msg void onsyscommand(uint nid, lparam lparam);     afx_msg void onpaint();     afx_msg hcursor onquerydragicon();     declare_message_map() private:     colorref ellipsecolor;     colorref centerrectcolor;     colorref rightrectcolor;     crect centerrect;     crect rightrect;     csize ellipse;     bool mousecaptured; }; 

implementation file:

#include "stdafx.h" #include "csit861a3 vasilkovskiy.h" #include "csit861a3 vasilkovskiydlg.h" #include "afxdialogex.h"  #ifdef _debug #define new debug_new #endif   // caboutdlg dialog used app  class caboutdlg : public cdialogex { public:     caboutdlg();  // dialog data     enum { idd = idd_aboutbox };      protected:     virtual void dodataexchange(cdataexchange* pdx);    // ddx/ddv support  // implementation protected:     declare_message_map() public:     afx_msg void onlbuttondown(uint nflags, cpoint point);     afx_msg void onlbuttonup(uint nflags, cpoint point);     afx_msg void onmousemove(uint nflags, cpoint point); };  caboutdlg::caboutdlg() : cdialogex(caboutdlg::idd) { }  void caboutdlg::dodataexchange(cdataexchange* pdx) {     cdialogex::dodataexchange(pdx); }  begin_message_map(caboutdlg, cdialogex)     on_wm_lbuttondown()     on_wm_lbuttonup()     on_wm_mousemove() end_message_map()   // ccsit861a3vasilkovskiydlg dialog     ccsit861a3vasilkovskiydlg::ccsit861a3vasilkovskiydlg(cwnd* pparent /*=null*/)     : cdialogex(ccsit861a3vasilkovskiydlg::idd, pparent) {     m_hicon = afxgetapp()->loadicon(idr_mainframe);      ellipsecolor = rgb(255, 0, 0);     centerrectcolor = rgb(0, 0, 0);     rightrectcolor = rgb(255, 0, 0);     centerrect.left = 40;     centerrect.top = 20;     centerrect.right = 55;     centerrect.bottom = 80;     rightrect.left = 75;     rightrect.top = 35;     rightrect.right = 90;     rightrect.bottom = 50;     ellipse.cx = 10;     ellipse.cy = 10;     mousecaptured = false; }  void ccsit861a3vasilkovskiydlg::dodataexchange(cdataexchange* pdx) {     cdialogex::dodataexchange(pdx); }  begin_message_map(ccsit861a3vasilkovskiydlg, cdialogex)     on_wm_syscommand()     on_wm_paint()     on_wm_querydragicon() end_message_map()   // ccsit861a3vasilkovskiydlg message handlers  bool ccsit861a3vasilkovskiydlg::oninitdialog() {     cdialogex::oninitdialog();      // add "about..." menu item system menu.      // idm_aboutbox must in system command range.     assert((idm_aboutbox & 0xfff0) == idm_aboutbox);     assert(idm_aboutbox < 0xf000);      cmenu* psysmenu = getsystemmenu(false);     if (psysmenu != null)     {         bool bnamevalid;         cstring straboutmenu;         bnamevalid = straboutmenu.loadstring(ids_aboutbox);         assert(bnamevalid);         if (!straboutmenu.isempty())         {             psysmenu->appendmenu(mf_separator);             psysmenu->appendmenu(mf_string, idm_aboutbox, straboutmenu);         }     }      // set icon dialog.  framework automatically     //  when application's main window not dialog     seticon(m_hicon, true);         // set big icon     seticon(m_hicon, false);        // set small icon      // todo: add initialization here      return true;  // return true  unless set focus control }  void ccsit861a3vasilkovskiydlg::onsyscommand(uint nid, lparam lparam) {     if ((nid & 0xfff0) == idm_aboutbox)     {         caboutdlg dlgabout;         dlgabout.domodal();     }     else     {         cdialogex::onsyscommand(nid, lparam);     } }  // if add minimize button dialog, need code below //  draw icon.  mfc applications using document/view model, //  automatically done framework.  void ccsit861a3vasilkovskiydlg::onpaint() {     //create pen , pointer old pen     cpen blackpen;      blackpen.createpen(ps_solid, 1, rgb (0, 0, 0));       //create bursh     cbrush blackbrush(centerrectcolor);     cbrush redbrush(rightrectcolor);     cbrush hatchredbrush(hs_cross, ellipsecolor);      //set object painting     cpaintdc dc (this);     crect rect;     getclientrect (&rect);     dc.setmapmode (mm_anisotropic);     dc.setwindowext (100, 100);     dc.setviewportext (rect.width (), rect.height ());       //select pen      dc.selectobject(&blackpen);      //rectangle red interior color     dc.selectobject(&redbrush);     dc.rectangle(rightrect); //(75, 35, 90, 50);      //rectangel black interior     dc.selectobject(&blackbrush);//select brush     dc.rectangle( centerrect);//(40, 20, 55, 80);      //ellipse     dc.selectobject(&hatchredbrush);//select brush     dc.ellipse(ellipse.cx, ellipse.cy, (ellipse.cx) + 10, (ellipse.cy) + 10);//10, 10, 20, 20);      if (isiconic())     {         cpaintdc dc(this); // device context painting          sendmessage(wm_iconerasebkgnd, reinterpret_cast<wparam>(dc.getsafehdc()), 0);          // center icon in client rectangle         int cxicon = getsystemmetrics(sm_cxicon);         int cyicon = getsystemmetrics(sm_cyicon);         crect rect;         getclientrect(&rect);         int x = (rect.width() - cxicon + 1) / 2;         int y = (rect.height() - cyicon + 1) / 2;          // draw icon         dc.drawicon(x, y, m_hicon);     }     else     {         cdialogex::onpaint();     } }  // system calls function obtain cursor display while user drags //  minimized window. hcursor ccsit861a3vasilkovskiydlg::onquerydragicon() {     return static_cast<hcursor>(m_hicon); }    void caboutdlg::onlbuttondown(uint nflags, cpoint point) {     // todo: add message handler code here and/or call default     //setcapture();     cclientdc dc(this);     crect rect;     getclientrect(&rect);     dc.setmapmode(mm_anisotropic);     dc.setwindowext(100, 100);     dc.setviewportext(rect.width(), rect.height());     crect rectellipse(10, 10, 20, 20);        cdialogex::onlbuttondown(nflags, point); }   void caboutdlg::onlbuttonup(uint nflags, cpoint point) {     // todo: add message handler code here and/or call default     releasecapture ();     cdialogex::onlbuttonup(nflags, point); }   void caboutdlg::onmousemove(uint nflags, cpoint point) {     // todo: add message handler code here and/or call default      cdialogex::onmousemove(nflags, point); } 

your onlbuttondown() member function of caboutdlg, trying access private, non-static data member of ccsit861a3vasilkovskiydlg, different class.

you meant have functions onlbuttondown(), onlbuttonup(), , onmousemove() member functions of ccsit861a3vasilkovskiydlg, , not member functions of caboutdlg.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -