ben1996123 0 Junior Poster in Training

I just made one, however after a short time or after a click, it just breaks and an image of the window appears within the window, and that image starts jumping around within the window, but the actual window stays where it is. I have no idea why this is happening and no idea how to fix it. Here is the code that I have in the case of WM_COMMAND:

if(LOWORD(wParam)==1){
                int a,b,c,d,e;
                e = 100;
                while(1){
                    a = rand()%1024;
                    b = rand()%768;
                    c = rand()%1024;
                    d = rand()%768;
                    MoveWindow(hwnd, a, b, c, d, FALSE);
                    Beep(e, 180);
                    if(e < 9000){
                        e += rand()%400;
                    }
                    else{
                        e = 100;
                    }
                    Sleep(220);
                }
            }

Any ideas as to why?