怎么用VB编写放大镜程序?

孤独勇敢洗衣机 2010-05-14 12:02:56
图像放大镜:在一个图像界面中,通过一个小图像框,图像框可按用户选择的放大率来显示相关区域的内容,小图像框可以移动,显示不同的区域。用户具有选择不同的放大率与设置小图像框大小的功能。

谁能帮帮忙哈
不用给我代码,只要给下主要的设计思路和用的算法什么的。
如果用API函数~请详细说下这个API函数~API还不太懂哈~才学1个月VB
谢谢!
...全文
512 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 cuizm 的回复:]
http://www.j2soft.cn/static_html/200511111905594187.html
这里有源码。写的很专业!
[/Quote]
这个太专业了,才学了1个多月,API的部分看不懂,看来还需要多家学习啊
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 chen8013 的回复:]
这些小程序,为什么很多人老喜欢在退出时,问‘是否真的要退出’呢!

人家不退出,点‘结束程序’干吗…… -_-b
重启程序很困难吗!
[/Quote]
怕他点错嘛
射天狼 2010-05-15
  • 打赏
  • 举报
回复
http://www.j2soft.cn/static_html/200511111905594187.html
这里有源码。写的很专业!
舉杯邀明月 2010-05-15
  • 打赏
  • 举报
回复
这些小程序,为什么很多人老喜欢在退出时,问‘是否真的要退出’呢!

人家不退出,点‘结束程序’干吗…… -_-b
重启程序很困难吗!
无·法 2010-05-14
  • 打赏
  • 举报
回复
新建个form,放一个timer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim pos As POINTAPI
Const srccopy = &HCC0020
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Dim shuai As Long
Private Sub start()
Dim sx As Integer
Dim sy As Integer
GetCursorPos pos
sx = IIf(pos.x < 50 Or pos.x > 925, IIf(pos.x < 50, 0, 925), pos.x - 50)
sy = IIf(pos.y < 50 Or pos.y > 680, IIf(pos.y < 50, 0, 680), pos.y - 50)
StretchBlt Me.hdc, 0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, GetDC(0), sx - 20, sy - 20, 40, 40, srccopy
End Sub

Private Sub Form_DblClick()
End
End Sub

Private Sub Form_Load()
Me.Height = Me.Width
shuai = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
SetWindowRgn Me.hWnd, shuai, True
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Dim usew As Double
Dim useh As Double
usew = Me.Width / Screen.TwipsPerPixelX
useh = Me.Height / Screen.TwipsPerPixelY
Timer1.Interval = 50
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
start
End Sub
贝隆 2010-05-14
  • 打赏
  • 举报
回复
StreachBlt函数可以放大图片
学习风 2010-05-14
  • 打赏
  • 举报
回复
这知识点有意思,关注!顶,,,,,,
  • 打赏
  • 举报
回复
猴哥你好哈~嘿嘿~哪里需要改进呢?~还需多指导下哦
chinaboyzyq 2010-05-14
  • 打赏
  • 举报
回复
路过的,你的程序有待改进。
  • 打赏
  • 举报
回复
自己解决了,呵呵
Dim w%, h%
Private Sub Form_Load()
Command1.Visible = False
Shape1.Visible = False
w = Shape1.Width
h = Shape1.Height
End Sub
'标准放大镜事件
Private Sub normal_Click()
'每次清屏p2,以防出现黑块,下同
Picture2.Cls
Shape1.Width = 375
Shape1.Height = 375
'调用重绘
Call one_Click
End Sub
'大号放大镜
Private Sub big_Click()
Picture2.Cls
Shape1.Width = 600
Shape1.Height = 600
Call one_Click
End Sub
'CMD子过程
Private Sub Command1_Click()
Shape1.Visible = True
Picture2.PaintPicture Picture1.Picture, 0, 0, w, h, Shape1.Left, Shape1.Top, Shape1.Width, Shape1.Height
End Sub
'放大1倍
Private Sub one_Click()
Picture2.Cls
w = Shape1.Width
h = Shape1.Height
End Sub
'放大2倍
Private Sub two_Click()
Picture2.Cls
w = Shape1.Width
h = Shape1.Height
w = w * 2
h = h * 2
End Sub
'4倍
Private Sub four_Click()
Picture2.Cls
w = Shape1.Width
h = Shape1.Height
w = w * 4
h = h * 4
End Sub
'6倍
Private Sub six_Click()
Picture2.Cls
w = Shape1.Width
h = Shape1.Height
w = w * 6
h = h * 6
End Sub
Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Shape1.Left = X
Shape1.Top = Y
Call Command1_Click
End Sub

Private Sub end_Click()
Dim i
i = MsgBox("你确定要退出吗?", vbOKCancel + vbQuestion, "提示框")
If i = vbOK Then
End
End If
End Sub

  • 打赏
  • 举报
回复
这个。。貌似是BAIDU COPY的?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧