invoke LoadBitmap,hInstance,IDB_1
GETDIM
invoke BitBlt,hdc,0,0,wide,tal,cdc,0,0,SRCCOPY
delete

invoke LoadBitmap,hInstance,IDB_2
GETDIM
invoke BitBlt,hdc,300,200,wide,tal,cdc,0,0,SRCCOPY
delete

invoke LoadBitmap,hInstance,IDB_3
GETDIM
invoke BitBlt,hdc,25,25,wide,tal,cdc,0,0,SRCCOPY
delete

invoke LoadBitmap,hInstance,IDB_4
GETDIM
invoke BitBlt,hdc,108,25,wide,tal,cdc,0,0,SRCCOPY
delete

invoke LoadBitmap,hInstance,IDB_5
GETDIM
invoke BitBlt,hdc,188,25,200,70,cdc,0,0,SRCCOPY
delete

The above code calls a macro..(GETDIM) that gets the dimensions of 5 bitmaps to display in my window. The delete macro restores the old bitmap info into the dc etc. The problem is I only want to have the text written once and so i would need to have the bitmap IDs in a variable as well as the static bitblt values. What is the solution? Do i put the static values in an array. Can i put the bitmap IDs in a variable such as.....

invoke LoadBitmap,hInstance,N

What i want to do is use a loop like....

.while N < 6

any help appreciated

thanx:alright:
Posted on 2001-08-16 12:30:34 by titan
There are several ways to do it, but the question is weather you want to produce a coded loop or an assemble-time loop that creates a non-looped execution path? A coded loop requires indexing into an array of IDs, and storing or pushing the dimensions. An assembler time loop requires no data, but instead requires passing an array of IDs to the macro.

Another idea is to write a macro that creates the coded loop - for ease of editing. Which would you like? This should duplicate the code you have:
theIDs TEXTEQU <IDB_1,IDB_2,IDB_3,IDB_4,IDB_5>

theXYWH TEXTEQU <<0,0,wide,tal>,<300,200,wide,tal>,<25,25,wide,tal>,<108,25,wide,tal>,<188,25,200,70>>
FOR arg,<1,2,3,4,5>
invoke LoadBitmap,hInstance,@ARRAY(arg, theIDs)
GETDIM
invoke BitBlt,hdc,@ARRAY(arg,theXYWH),cdc,0,0,SRCCOPY
delete
ENDM

All you need is the macro called @ARRAY that returns the element text of an array of values. I just so happen to have this from the MASM documentation (which does just that, but it's called something else :)):
@ArgI MACRO index:REQ, arglist:VARARG

LOCAL count, retstr
count = 0
FOR arg, <arglist>
count = count + 1
IF count EQ index
retstr TEXTEQU <arg>
ENDIF
ENDM
EXITM retstr
ENDM


Sorry, I haven't tested any of this code!
Posted on 2001-08-16 18:09:08 by bitRAKE