Hi,
I am trying to access globally variables declared in MainFrame of my solution from a thread that starts in my CMyView.cpp. How can I access these parameters without the
CMainFrame * _MainFrame; in my structure
THREADVIEW in CMyView.h, as below? Any ideas?
typedef struct THREADVIEW{
* _this;
} THREADVIEW;
Many thanks,
Yoldas
addition by the OP:
Hi,
First of all many thanks for your immediate comments. Here are the things in more detail.
void CView::OnSprint()
{
CMainFrame *pFrame = (CMainFrame*) AfxGetMainWnd();
.
.
.
THREADVIEW *_pview = new THREADVIEW;
_pview->_this = this;
AfxBeginThread(ChangeColorThread, _pview);
}
UINT CView::ChangeColorThread(LPVOID param)
{
THREADVIEW * thd = (THREADVIEW*)param;
thd->_this->StateOnThread();
AfxEndThread(1, FALSE);
return 1;
}
void CView:: StateOnThread ()
{
CMainFrame *pFrame = (CMainFrame*) AfxGetMainWnd();
int a = pFrame->AA;
}
public:
typedef struct THREADVIEW{
CView * _this;
} THREADVIEW;
void StateOnThread();
static UINT ChangeColorThread(LPVOID param);
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
int AA;
}
which I am trying to access. My thread kicks off from toolbar button after the child frame is displayed but I do not see why this has anything to do with why I cannot access Cmainframe parameters.
I greatly appreciate your input.
Regards,
Yoldas