Sep 5, 2010 at 1:20pm UTC
I wanna use a variable identified in NameDlg.h in another class and i dont know what i should do.
I made a pointer pointing to "this "(!) in Dlg.cpp file but i cant use it.
my code is here:
(CMynameDlg *)pointer)->My_variable
the compilation error is : "undeclared identifier "
Please help me!
Sep 5, 2010 at 5:02pm UTC
Would you care to post the class declaration?
Sep 6, 2010 at 6:16am UTC
this is the class that i wanna use the variable in it :
#pragma once
#include "khiaboon.h"
#include "cheragh.h"
// mashin dialog
class mashin : public CDialog
{
DECLARE_DYNAMIC(mashin)
public:
mashin(CWnd* pParent = NULL); // standard constructor
virtual ~mashin();
// Dialog Data
enum { IDD = IDD_MASHIN };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
//khod barnamegi!!!
public:
int x, y;
bool h, u, l, s; //,p; //p = peigham or not
int v;
COLORREF rang;
khiaboon * kh;
CDialog * pointer;
void show(COLORREF);
void setparent(CDialog*);
void set();
void move();
void bargasht();
void check_ch();
};
and this is the main class (NameDlg.h) :
// 31.4.89Dlg.h : header file
//
#pragma once
//#include "khiaboon.h"
#include "mashin.h"
#include "cheragh.h"
// CMy31489Dlg dialog
class CMy31489Dlg : public CDialog
{
// Construction
public:
CMy31489Dlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_MY31489_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()
//khod barnamegi!!!
public:
mashin m[100];
khiaboon k[100];
ccheragh c[49];
int cted, kted, mted;
void setk(void);
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedButton2();
afx_msg void OnTimer(UINT_PTR nIDEvent);
};
the variable that i want to use is "cted", and the pointer that i made to point to CDialog is "pointer"