Click to See Complete Forum and Search --> : Loops in WM_COMMAND
SteveCRM
Jul 14th, 2001, 01:53 PM
Im making version 2 of my checkers (no parksie, not draughts, but checkers) game. I want to make the user able to click the pieces to move them (click once, and then another where to move it) So instead of putting my moving and jumping code in 64 times :eek: I decidied to put a nested loop in my WM_COMMAND statement to keep checking if 1 of the 64 square (statics) were cliicked. But I'm getting no reaction. Any Help? :)
Wynd
Jul 14th, 2001, 04:59 PM
Just curious, but was it me who gave you that idea? Cause I know i said it would be better...
Anyway, post the loop, it would help me to see where it goes wrong.
kedaman
Jul 14th, 2001, 06:21 PM
WM_COMMAND message is sent to the window proc if you click a menu item, maybe you should check for WM_LBUTTONDOWN instead?
SteveCRM
Jul 14th, 2001, 07:03 PM
WM_LBUTTONDOWN does work
might have been you wynd :)
case WM_LBUTTONDOWN:
for(i=1; i<=8; i++) {
for(a=1; a<=8; a++) {
if(LOWORD(wParam) == BN_CLICKED && (HWND)lParam == Board[a][i]) {
int x;
int y;
int Finalx;
int Finaly;
char buff[5];
char buff2[5];
//this section gets the x and y values
sprintf(buff, itoa(a,buff2,10));
sprintf(buff, " , ");
sprintf(buff, itoa(i, buff2,10));
MessageBox(hWnd, buff, "X , Y", MB_OK);
}
}
}
all it does is have a messagebox say the a and i values.....:confused:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.