Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Load images into a form using GDIPlus library
Message
From
06/10/2004 14:36:47
Walter Nicholls
Cornerstone Software Ltd
Auckland, New Zealand
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00949200
Message ID:
00949299
Views:
10
Joel is right when he points out the hWND is not a graphics handle. This will be the cause of the exception on your DrawImageScaled call.

oGDI = CREATEOBJECT("GPGraphics")
oGDIImage = CREATEOBJECT("GPImage")
* NOT this: ?oGDI.SetHandle(oForm.HWnd)
* but this instead
oGDI.CreateFromHWND( oForm.HWND )
* Also not this for same reason: ?oGDIImage.SetHandle(oForm.HWnd)
* But this was correct:
?oGDIImage.CreateFromFile("C:\SampleImage.jpg")

* You shouldn't get an exception here now!
?oGDI.DrawImageScaled(oGDIImage, oForm.ctrShape.Left, oForm.ctrShape.Top, oForm.ctrShape.Width, oForm.ctrShape.Height)

Of course, your code would be a lot simpler for this particular case if you simply used a Fox Image control and set Thisform.Image1.Picture = "c:\sampleimage.jpg" - I assume that you have a more difficult task in mind and this is just your path towards it. Good luck!

- Walter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform