I have a form with 30 - 50 image controls each displaying a transparent background GIF. The images themselves are irregular. The controls are overlapped, creating a mosaic effect, much like a puzzle with each image control containing one piece of the puzzle.
When the user clicks on the mosaic of images, he wants to know which piece has been clicked on.
Current code to determine which control has been clicked looks something like this...
LPARAMETER pnX, pnY
#DEFINE dnWhite RGB(255,255,255)
WITH thisform
FOR EACH oCtrl IN .Controls
IF "Vf_images" $ oCtrl.Class ;
AND BETWEEN(pnX, oCtrl.Left, oCtrl.Left + oCtrl.Width) ;
AND BETWEEN(pnY, oCtrl.Top, oCtrl.Top + oCtrl.Height)
oImage.Load(oControl.Picture)
IF oImage.GetPixelColor(pnX - oCtrl.Left, pnY - oCtrl.Top) # dnWhite
ENDIF
ENDIF
ENDFOR
ENDWITH
The problem is the line oImage.Load(oControl.Picture). To process each image control until I get the desired one can take for 1 to 3 seconds depending on how far down the control list the image control is.
I saw a function in GDI+ called FromPicture(). It takes a picture object as a parameter and appears to replace the Load() function. The only problem is that when I try to use it and pass in the Image object, I get any error.
Any suggestions.
Thank you.