Can someone explain to me
alrite, i keep it short, this function is for looping through the coordinates of known starting X and Y axis, incrementing X most of the time and when X is at the max of Client area which is around 307, it will reset X to 125 and Y will increase. This function is used in WM_LBUTTONDOWN to correctly pinpoint whether an icon was clicked. Ok, here cums the problem.
void CalculateMousePoint(int MaxCount,int minX,int minY,int MouseX,int MouseY)
int i=0; // for loop
int noteWidth = 54;
int noteHeight = 50;
static int maxX;
static int maxY;
maxX = minX + noteWidth;
maxY = minY + noteHeight;
// check if mouse is within any note bitmaps
if ( MouseX > minX && MouseX < maxX && MouseY > minY && MouseY < maxY )
i = MaxCount;
else if ( maxX >= 307 )
minX = 125;
minY += noteHeight + 20;
// pls think of a loop to solve the problem
// this is for checking and increment max n min values
minX += noteWidth + 20;
i started this function by declaring the variables as normal int maxX,maxY and the loop failed and even freeze when it reaches if(maxX >= 307), i narrowed the search and found the culprit was minY += iconHeight + 20; i figured for almost 2 days where did i do wrong and around 5 mins earlier, i added static into my variables and the loop worked, but the funny thing is maxX do not require static and it still worked ?!?!
Can someone explain to me how does the static cum into place. Static is mainly used to retain the value within the variable but why doesn't maxX require it ???