Moving A Picture..slight prob
Hey, I'm having a weird problem( I havn't done windows programming in several months so don't get mad at me). I am trying to make it so when the user presses right, the picture goes right one space. Here is my code for WM_PAINT:
Code:
case WM_PAINT:
{
if(moveright == TRUE)
{
hDC = BeginPaint(hWnd, &ps);
hBitmap = (HBITMAP)LoadImage(NULL, "C:\\Visual C++\\Game\\none.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, picx, picy, picsizex, picsizey, DST_BITMAP | DSS_NORMAL);
picx+=4;
hBitmap = (HBITMAP)LoadImage(NULL, "C:\\Visual C++\\Game\\guy.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, picx, picy, picsizex, picsizey, DST_BITMAP | DSS_NORMAL);
}
//WM_PAINT goes on...
anyway, when I press right it goes right through WM_PAINT and goes through moveright==true. I know this because when I press right, it only shows my guy once. When I press it again, he doesn't move at all. He just stays in the same place. Help? Thanks in advance.
Just use a "static" window...
Like this:
int px=0;
HWND hStatic;
hStatic=CreateWindow(
"static", NULL,
WS_CHILD | WS_VISIBLE | SS_BITMAP,
0, 0, 300, 300, // Change 300, 300 to the image width/height
hwnd,
0,
0,
0
);
// Code
case WM_KEYDOWN:
switch(LOWORD(wParam))
{
case VK_RIGHT:
px+=1;
SetWindowPos(hStatic, 0, 0, 0, px, 0, FALSE);
}
break;
or something like that...