利用GDI实现浏览图片的ActiveX控件,功能:支持读取PNG格式的图片,支持鼠标飞轮对图片进行缩放,镜像,移动等功能,其中用到了功能强大的GDI,GDI+,对初及vb编程爱好者运用GDI-API有很大的研究价值,控件利用GDI实现了基本功能,更多功能大家自己扩展。
Form代码:
'放大图像
Private Sub Fangda_Click()
DisplayMap1.Enlarge
End Sub
'加载图像
Private Sub Form_Load()
DisplayMap1.LoadImage = (App.Path & “\VB源码编程.png”)
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then Exit Sub
DisplayMap1.Move 10, 10, Me.ScaleWidth - 20, Me.ScaleHeight - 20
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim frm As Form
For Each frm In Forms
Unload frm
Next
End Sub
'适应控件窗口
Private Sub Huanyuan_Click()
DisplayMap1.ScreenFit
End Sub
'镜像
Private Sub MirrorImage_Click(Index As Integer)
Dim N As Integer
For N = 0 To 3
MirrorImage(N).Checked = False
Next
MirrorImage(Index).Checked = True
DisplayMap1.MirrorImage = Index
End Sub
'是否任意移动图像
Private Sub Rmov_Click()
Rmov.Checked = IIf(Rmov.Checked, False, True)
DisplayMap1.Boundary = Rmov.Checked
End Sub
'缩小图像
Private Sub Suoxiao_Click()
DisplayMap1.Shrink
End Sub
工程包下载:https://download.csdn.net/download/ty5858/87815530