,图片框显示了以下类型的图片:
创新互联是专业的太平网站建设公司,太平接单;提供做网站、网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行太平网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
位图(*。BMP,DIB)
GIF图像(*。GIF)
JPEG图像(*。JPG)
图元文件(WMF *。EMF)
图标(*。ICO,*。姜黄素)
二,PictureBox的输出为BMP图像。
如果你想保存为其他类型的图像,你必须完成相关的API函数。
添加一个模块,输入以下代码:
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Const GWL_WNDPROC = -4
Public Const WM_MOUSEWHEEL = H20A
Public Type POINTAPI
x As Long
y As Long
End Type
Public OldWindowProc As Long
Public ohwnd As Long
Public Function NewWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
If Msg = WM_MOUSEWHEEL Then
Dim CurPoint As POINTAPI, hwndUnderCursor As Long
GetCursorPos CurPoint
hwndUnderCursor = WindowFromPoint(CurPoint.x, CurPoint.y)
If hwndUnderCursor = ohwnd Then
If wParam = -7864320 Then
If Form1.Picture1.Width Form1.ScaleWidth Then Form1.Picture1.Width = Form1.Picture1.Width + 300
If Form1.Picture1.Height Form1.ScaleHeight Then Form1.Picture1.Height = Form1.Picture1.Height + 240
ElseIf wParam = 7864320 Then
If Form1.Picture1.Width 600 Then Form1.Picture1.Width = Form1.Picture1.Width - 300
If Form1.Picture1.Height 480 Then Form1.Picture1.Height = Form1.Picture1.Height - 240
End If
End If
Else
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, Msg, wParam, lParam)
End If
End Function
在Form1中放入一个Picture1控件,然后输入以下代码:
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.Picture = LoadPicture("e:\tmp\cd1.gif") '图片文件名,自己改
Picture1.Move 0, 0, 6000, 4800
ohwnd = Picture1.hwnd
OldWindowProc = GetWindowLong(Picture1.hwnd, GWL_WNDPROC)
Call SetWindowLong(Picture1.hwnd, GWL_WNDPROC, AddressOf NewWindowProc)
End Sub
Private Sub Picture1_Resize()
Picture1.PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
End Sub
根据我的经验,应该是PICtureBox没有获取焦点,而win10下不知道什么原因能自动获取焦点,所以凑巧成功了,因此你应该让图形框获取焦点
如:picturebox1.focus()
不知道是不是解决了你的问题
缩放操作
Function 缩放(ByVal bitmap As Bitmap, ByVal 倍数 As Single) As Bitmap
Dim w As Integer = bitmap.Width * 倍数
Dim h As Integer = bitmap.Height * 倍数
Dim tem As New Bitmap(w, h)
Dim g As Graphics = Graphics.FromImage(tem)
g.DrawImage(bitmap, New Rectangle(0, 0, w, h), New Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel)
g.Dispose()
Return tem
End Function
鼠标滚轮事件 MouseWheel
MouseEventArgs.Delta 值可以判断滚动方向
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款