Picture methods and properties
The Height and Width properties of a picture are different from the Height and Width properties of a form or a picture box. The latter properties have values in the current scale mode (which is twips by default), but the Height and Width properties of a picture always have values in the standard COM mode, vbHimetric (MM_HIMETRIC). Visual Basic wouldn’t let you set the scale mode to vbHimetric, even if you had some bizarre reason for doing so. Normally you’ll convert all your widths and heights to twips or pixels.
The ScaleX and ScaleY methods are the easiest way to convert from vbHimetric units to twips. For example, the statement ScaleX(Picture.Width) converts to twips. Pixels are messier. Sometimes when you’re dealing with API functions, you’ll need to do a conversion without benefit of an object that has ScaleX and ScaleY methods. In that case, you can use the conversion constants and functions in PICTOOL.BAS. Here are several similar statements:
dxBlt = pic.Width * TwipsPerMillimeter / Screen.TwipsPerPixelX / 100
dxBlt = pic.Width * TwipsPerHiMetricUnit / Screen.TwipsPerPixelX
dxBlt = PicXToPixel(pic.Width)
dxBlt = frm.ScaleX(pic.Width, pvHiMetric, vbPixel)
I’ll let you look up TwipsPerMillimeter, PicXToPixel, and similar conversions in the source code.
The Type property always returns 0 (vbPicTypeNone), 1 (vbPicTypeBitmap), 2 (vbPicTypeMetafile), 3 (vbPicTypeIcon), or 4 (vbPicTypeEMetafile). You can also load a cursor into a picture; the Type property will show it as vbPicTypeIcon.
The Handle and hPal properties are the link between the Basic Way of pictures and the Windows Way of GDI objects. The hPal property is the handle of the palette for bitmaps. (It’s meaningless for icons or metafiles because these don’t have palettes.)
The Handle property is the handle of the bitmap, icon, or metafile within the picture. You can have lots of fun with these object handles, as you’ll see later. The Handle property is the default member. When you assign a value to a Picture property, you’re actually assigning it to the handle. For example, the code
imgCur.Picture = LoadPicture(“Thing.Ico”)
actually means:
imgCur.Picture.Handle = LoadPicture(“Thing.Ico”)