boroangel
01-09-2005, 03:58 AM
Can anyone help me modify this code so that I can use the Gdiplus library to display the png files? I click on references on add the libraries but dont know which code to add to my existing code.
This is my code:
Option Explicit
Private Sub Form_Load()
On Error Resume Next
'ADDED THIS LINE
set imgBOX.Picture = LoadPicture("PATH TO YOUR IMAGE")
picBOX.AutoRedraw = True
scrVERT.Max = ScaleY(imgBOX.Picture.Height, vbHimetric, vbPixels) - ScaleY(picBOX.ScaleHeight, vbTwips, vbPixels)
scrHOR.Max = ScaleX(imgBOX.Picture.Width, vbHimetric, vbPixels) - ScaleX(picBOX.ScaleWidth, vbTwips, vbPixels)
'just setting these to larger values to have faster scroll
scrVERT.SmallChange = 50
scrVERT.LargeChange = 100
scrHOR.SmallChange = 50
scrHOR.LargeChange = 100
'paint the top left of the picture to the size of the picture box
picBOX.PaintPicture imgBOX.Picture, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight
End Sub
Private Sub scrHOR_Change()
On Error Resume Next
MovePic
End Sub
Private Sub scrVERT_Change()
On Error Resume Next
MovePic
End Sub
Private Sub MovePic()
On Error Resume Next
picBOX.Cls
picBOX.PaintPicture imgBOX.Picture, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight, ScaleX(scrHOR.Value, vbPixels, vbTwips), ScaleY(scrVERT.Value, vbPixels, vbTwips), picBOX.ScaleWidth, picBOX.ScaleHeight
End Sub
Private Sub scrVERT_Scroll()
On Error Resume Next
MovePic
End Sub
Private Sub scrHOR_Scroll()
On Error Resume Next
MovePic
End Sub
I have attached the gdiplus library
This is my code:
Option Explicit
Private Sub Form_Load()
On Error Resume Next
'ADDED THIS LINE
set imgBOX.Picture = LoadPicture("PATH TO YOUR IMAGE")
picBOX.AutoRedraw = True
scrVERT.Max = ScaleY(imgBOX.Picture.Height, vbHimetric, vbPixels) - ScaleY(picBOX.ScaleHeight, vbTwips, vbPixels)
scrHOR.Max = ScaleX(imgBOX.Picture.Width, vbHimetric, vbPixels) - ScaleX(picBOX.ScaleWidth, vbTwips, vbPixels)
'just setting these to larger values to have faster scroll
scrVERT.SmallChange = 50
scrVERT.LargeChange = 100
scrHOR.SmallChange = 50
scrHOR.LargeChange = 100
'paint the top left of the picture to the size of the picture box
picBOX.PaintPicture imgBOX.Picture, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight
End Sub
Private Sub scrHOR_Change()
On Error Resume Next
MovePic
End Sub
Private Sub scrVERT_Change()
On Error Resume Next
MovePic
End Sub
Private Sub MovePic()
On Error Resume Next
picBOX.Cls
picBOX.PaintPicture imgBOX.Picture, 0, 0, picBOX.ScaleWidth, picBOX.ScaleHeight, ScaleX(scrHOR.Value, vbPixels, vbTwips), ScaleY(scrVERT.Value, vbPixels, vbTwips), picBOX.ScaleWidth, picBOX.ScaleHeight
End Sub
Private Sub scrVERT_Scroll()
On Error Resume Next
MovePic
End Sub
Private Sub scrHOR_Scroll()
On Error Resume Next
MovePic
End Sub
I have attached the gdiplus library