-
bitmaps and controls..
hey, i want to use AnimateWindow() to animate my bitmaps (5 die) sliding onto the screen. but when i load / display my bitmaps, they're exactly that - not windows. so how could i load the bitmap into / as a static control so that i could animate it?
thanks.
-
mm...i'm thinking i found what i wanted. but in case anyone else ever needs to know.. http://msdn.microsoft.com/library/de...tic_styles.asp
...along with STM_SETIMAGE, lol http://msdn.microsoft.com/library/de...m_setimage.asp
:)
cept idk how to use them to make them work. whats wrong with..
Code:
in WM_CREATE
int dice = 1000;
for (i = 0; i < 6; i++)
{
dice1[i] = LoadBitmap(g_hInst, MAKEINTRESOURCE(dice));
OR
dice1[i] = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(dice), IMAGE_BITMAP, 64, 64, 0);
if (dice1[i] == NULL)
MessageBox(NULL, "Could not load the Dice", "Error", MB_OK | MB_ICONERROR);
++dice;
}
dieA = CreateWindowEx(0, TEXT("STATIC"), TEXT(""), WS_VISIBLE | WS_CHILD | SS_BITMAP | SS_CENTERIMAGE,
34, 20, 64, 64, hwnd, (HMENU)ID_CONTAINER1, g_hInst, NULL);
SendMessage(dieA, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)dice1);
OR
dieA = CreateWindowEx(0, TEXT("STATIC"), TEXT("#dice1"), WS_VISIBLE | WS_CHILD | SS_BITMAP | SS_CENTERIMAGE,
34, 20, 64, 64, hwnd, (HMENU)ID_CONTAINER1, g_hInst, NULL);
in WM_PAINT
BITMAP bm1;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcMem1 = CreateCompatibleDC(hdc);
HBITMAP hbmOld1 = SelectObject(hdcMem1, dice1[dieOne]);
GetObject(dice1[dieOne], sizeof(bm1), &bm1);
SelectObject(hdcMem1, hbmOld1);
DeleteDC(hdcMem1);
EndPaint(hwnd, &ps);
?
dieOne = 0
do i even need the code in the wm_paint case?
-
Check the returns from your functions to find which fails.
ie SendMessage() should return the last bitmap for you to free the resource.
SendMessage() with dice1[0] .
Then SendMessage() dice1[1] and the return should be equal to dice1[0]
I think that the bitmap has to be a resource ID number if using it during CreateWindow().
also could be
(LPARAM)dice1[0]
>>so how could i load the bitmap into / as a static control so that i could animate it?
MFC has an animation control....CAnimateCtrl
I would look at GDI and draw it myself. Much faster and better control.
Plenty of code here for 'double buffering'.
Once you learn to handle GDI drawing skinning and animations are easy.
-
The return value from SendMessage() is 0...
:( i really dont understand whats not being done right. lol
but for some reason it does show a pink line (O_o) ?
Code:
dieA = CreateWindow("static", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 34, 20, 64, 64,
hwnd, (HMENU)ID_CONTAINER1, g_hInst, NULL);
if (dieA == NULL)
MessageBox(NULL, "dieA is null, that window was not created.", "error", MB_OK);
lReturn = SendMessage(GetDlgItem(hwnd, ID_CONTAINER1), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)ID_DIE1);
pic: http://img.photobucket.com/albums/v4...imageerror.jpg
but the line doesn't appear if i change GetDlgItem() in SendMessage to dieA. it just fails. lol
what is there for GDI+ tutorials? i searched google but i must suck at it :( lol
bah...you kids and your MFC. ;]
I tried making a window and specified the ID of a bitmap instead of trying to use an HBITMAP and there was still no go. i think i suck at this game :( lol but i will look in to GDI. i like speed :)
thats why i use C instead of VB ^_^ but skinning would be fun too..
thanks