Rotate Through Bitmaps on WM_LBUTTONDOWN
Mar 9, 2014 at 11:33am UTC
Hi,
Bit of a newbie here
I'm trying to change bitmaps on click of WM_LBUTTONDOWN, I've managed to get this working with the following code;
1 2 3 4 5 6 7 8 9 10 11 12
case WM_LBUTTONDOWN:
{
if (hWnd == hWndImages)
{
HBITMAP hSample;
hSample = LoadBitmap (hBmpLibInst, MAKEINTRESOURCE(IMAGEONE));
SendMessage ( hWnd, IM_SETBMPHANDLE,(WPARAM)TRUE, MAKELONG(IMAGEONE, NULL) );
}
return (TRUE);
}
break ;
Now I want to be able to load another image if I click on the bitmap again if Image one is loaded, I've tried doing with with a switch statement but can't get it to work;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
if (hWnd == hWndhWndImages)
{
HBITMAP hSample;
int i = 0;
{
i++;
switch (i)
{
case 1:
hSample = LoadBitmap (hBmpLibInst, MAKEINTRESOURCE(IMAGEONE));
SendMessage ( hWnd, IM_SETBMPHANDLE,(WPARAM)TRUE, MAKELONG(hSample, NULL));
break ;
case 2:
hSample = LoadBitmap (hBmpLibInst, MAKEINTRESOURCE(IMAGETWO));
SendMessage ( hWnd, IM_SETBMPHANDLE,(WPARAM)TRUE, MAKELONG(hSample, NULL));
break ;
}
}
}
return (TRUE);
}
break ;
Any help would be much appreciated.
Cheers
Mar 9, 2014 at 2:25pm UTC
Define int i as static
and possibly make it 0 again if you exceed maximum number of images.
Topic archived. No new replies allowed.