Cruising the units_32 file in VB

GIDustin

Emperor
Joined
Nov 11, 2001
Messages
1,392
Location
Spearfish, SD
I am new to VB and need some advice. How would i open units_32.pcx and dispaly the icon at Coords X,Y, where X and Y will be changing quite often? I assume a sub would do it, but I need that particular icon to appear on the screen (Much like the units tab in the civ 3 editor). Also, I will need to gather the icon number, and I know that units_32 files are variable height and width, so it might get difficult.

Thanks in advance

GIDustin
 
What I would use is bitblt. You will need two picture boxes, one with the uits_32.pcx loaded into it, you will want to make the picture box hidden, and one that is 33 x 33 pixels for the unit icon. Bitblt copies a section from x, y to *I think* another x, y. I will try to dig up what I have about bitblt and post it later because I was just about to start a project using bitblt. As for the icon # i am sure you can make some kind of mathematical formula using the fact that each unit box is 33 x 33 from line to line.
 
Your information (if it works) would work. (Obviously). Now all i need is a way to determine the height and width of the file so as to find out how many rows/columns of icons there are.

I am sure this one is easy for most of you, but I havent stepped foot outside of CGI/Perl until yesterday. :D

Thanks

GIDustin
 
You can also use the VB version of BitBlt, PaintPicture.
From MSDN:
object.PaintPicture picture, x1, y1, width1, height1, x2, y2, width2, height2, opcode

object: New pic
picture: The picturebox you want to cut picture from
x1,y1: Coordinates to start new drawing on in object
width1, height1: size of new drawing, (should be omitted, since it will resize the drawing)
x2,y2: Where to start cut from old picture
width2,height2: How much to cut from old picture
opcode: Special commands( skip it)

Code:
newpic.PaintPicture oldpic, 35, 40, , , 10, 15, 20, 33

This code will:
-Draw a new picture at coordinate (35,40) in newpic, with the same size as the source
-The new picture is taken from oldpic, a square with the coordinates (10,15)-(10+20, 15+33)

If you're new, it's easier to use the built-in functions in VB than using APIs. OTOH APIs are good to know:)
 
Back
Top Bottom