David,
To centre an image in a picture box, the easiest way is to use the BitBlt
API call, which allows you to set the X and Y co-ordinates where you want
to put the picture.
Pop this code in the form you are using. You only need to use one of the
constants declared, but experiment with the others, because you get some
interesting results.
'CODE:DECLARATIONS
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long,_
ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long)_
As Long
Private Const SRCAND = &H8800C6
Private Const SRCCOPY = &HCC0020
Private Const SRCERASE = &H440328
Private Const SRCINVERT = &H660046
Private Const SRCPAINT = &HEE0086
'CODE: THE DRAWING BIT
Dim lXPos As Long
Dim lYPos As Long
picSource.ScaleMode = vbPixels
picDest.ScaleMode = vbPixels
lXPos = (picDest.ScaleWidth - picSource.ScaleWidth) \ 2
lYPos = (picDest.ScaleHeight - picSource.ScaleHeight) \ 2
BitBlt picDest.hDC, lXPos, lYPos, picSource.ScaleWidth, _
picSource.ScaleHeight, picSource.hDC, 0, 0, SRCCOPY
'END CODE
The above assumes that you have two picture boxes, picSource containing
the picture you want to centre, and picDest beign the picture box that the
image needs to appear in the middle of.
As for the book, see if you can find "Visual Basic Graphics Programming"
by Rod Stephens. It is the best book on graphics programming I've found
(and I have spent a long time looking). Starts wit hte basics of graphics
manipulation (like the code above), and goes thriugh to the hard-core
stuff, like povray and lighting effects. Highly recommended (although it
is an advanced book - you need pretty good maths skills to work through
the entire book. Its ISBN is 0-471-15533-0
Cheers
Matt
---
You are currently subscribed to pro_vb as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-pro_vb-$subst('Recip.MemberIDChar')@p2p.wrox.com