Reputation: 35
I was given a assignment at the university: to write a game in MASM
. I chose a game the type of "three in a row". Objects in the game are some sweets: ice cream, lollipop, etc. But I have a problem. I don't know how to make child windows with different images. I've tried, but nothing is working. Maybe someone knows how to implement this? Any help is appreciated. Even in C/C++
. I would be glad if someone just explain to me in words how to do it. The main thing for me is to understand the concept.
I have
But I need this
Upvotes: 0
Views: 113
Reputation: 1667
Of course you have JUST ONE IMAGE, because hBit IS A GLOBAL VARIABLE, hBit is overwritten in all calls to CreateSweetsWindow, in fact: it retains last image loaded.
I suggest you add hBit to SweetsWindowStruct struct:
SweetsWindowStruct struct
stype SWEETSTYPE ?
sweetsID DWORD ?
hBit HBITMAP ?
SweetsWindowStruct ends
And remove global hBit (line 44 in your sweets.asm file), you must change WM_PAINT code like this:
.elseif [iMsg] == WM_PAINT
invoke BeginPaint, [hwnd], addr ps
mov [hdc], eax
invoke CreateCompatibleDC, hdc
mov [hMemDC], eax
SweetsWindowStruct *sws;// sorry show you in c++
sws = (SweetsWindowStruct*)GetWindowLong(hwnd, GWL_USERDATA);
HBITMAP hBit = sws->hBit;
invoke SelectObject, hMemDC, [hBit]
mov [oldDC], eax
Other issue: i think you have a error, where you say:
invoke SetWindowLong, [hwnd], 0, addr [sws]
it must be:
invoke SetWindowLong, [hwnd], GWL_USERDATA, addr [sws]
Please check that
Upvotes: 3