1. You have a memory leak now, fix:
void CYourView::OnSprint()
{
THREADVIEW sPar = { this }; AfxBeginThread(ChangeColorThread, &sPar); }
2. Your thread parameter could contain the CMainFrame-pointer:
typedef struct {
CYourView* pView;
CMainFrame* pFrame;
} THREADVIEW;
void CYourView::OnSprint()
{
THREADVIEW sPar = { this, static_cast<CMainFrame*>(::AfxGetMainWnd()) };
AfxBeginThread(ChangeColorThread, &sPar);
}
3. Your StateOnThread could return the value or even the reference of the frame variable:
int CYourView::StateOnThread()
{
CMainFrame* pcFrame(static_cast<CMainFrame*>(AfxGetMainWnd()));
return pcFrame ? pcFrame->AA : 0;
}
4. Do not use this kind of access for the types longer as INT_PTR :)