導航:首頁 > 編程語言 > 在編程中如何將圖片放大

在編程中如何將圖片放大

發布時間:2025-01-23 04:24:09

❶ 請教:用vb編程如何實現用滑鼠滾輪擴大和縮小窗體上的圖片

添加一個模塊,輸入以下代碼:

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

閱讀全文

與在編程中如何將圖片放大相關的資料

熱點內容
伺服器地址缺少埠號什麼意思 瀏覽:527
下載需要解壓的小說用哪個軟體 瀏覽:531
廣東分布式伺服器雲主機 瀏覽:580
伺服器忙打不開怎麼辦 瀏覽:12
tif壓縮軟體 瀏覽:410
程序員那麼可愛陸漓上班第1天 瀏覽:950
macbookair自帶什麼app 瀏覽:698
如何關了加密的軟體 瀏覽:579
程序員p2p待遇 瀏覽:920
ipd編譯要求 瀏覽:935
壓縮解壓王怎麼用 瀏覽:33
伺服器共享文件如何備份 瀏覽:757
買安卓手機怎麼在官網買 瀏覽:125
詩詞入門PDF 瀏覽:363
毒app是什麼單位 瀏覽:66
如何自己編譯android系統 瀏覽:794
phpmysqlpdomysqli 瀏覽:810
php修改sql語句 瀏覽:722
android有道api 瀏覽:390
撓耳營水表用的什麼app 瀏覽:57