thanks for, you help, I have modified the code to this:
class CRegState
{
public:
char* label;
RECT state;
};
// ************* LIST DECLARATION *****************************
CList<CRegState,CRegState&> statelist;
// ************************************************************
void CRegister::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect rect;
CRegState *thisstate;
char* slabel;
// check Ok button has been clicked
if (onclicked == TRUE)
{
thisstate = new CRegState; //create a new CRegState instance
int mouseX=(point.x-20);
int mouseY=(point.y-20);
CClientDC dc(this); // Device context for painting etc
//rect.Ellipse(mouseX,mouseY,mouseX+50,mouseY+50);
dc.Ellipse(mouseX,mouseY,mouseX+50,mouseY+50);
rect = CRect(mouseX,mouseY,mouseX+50,mouseY+50);
dc.TextOut(mouseX+20,mouseY+16,str);
onclicked = FALSE;
thisstate->label = str;
thisstate->state = rect;
statelist.AddHead(*thisstate);
}
// test to see if in ellipse
POSITION pos = statelist.GetHeadPosition( );
while (pos)
{
*thisstate = statelist.GetNext(pos);
if(PtInRect(thisstate.state,point)) {
slabel = thisstate.label;
MessageBox(slabel,"You're inside!",MB_OK);
}
}
}
but I get the following errors:
:\My Documents\STAR\Register.cpp(145) : error C2228: left of '.state' must have class/struct/union type
Z:\My Documents\STAR\Register.cpp(146) : error C2228: left of '.label' must have class/struct/union type
Error executing cl.exe.
and I don't understand how to correct them, also I have compiled the program without the code checking if I'm in the ellipse and it still seems to be setting all the elements in the list to that of the head, can you tell me where I am going wrong? Once again thanks for your time and help.