我用vb做了一个放大镜程序,但并不是只一个放大镜,而是嵌入到一个图形显示程序中的。也就是一点click键就执行放大镜程序但是没法退出,只有关闭vb才可以推出。我的想法是再次点击这个键停止放大镜程序,也就是只退出这个程序别的都不变。望知道者告诉怎么做,给出代码最好
解决方案 »
- 请问用CreateObject("Excel.Application") 后.怎么判断调用的EXCEL关了没?
- 我我我我我我.......
- 问题很多.也很简单,,,懂一点的都可进来.....
- 如何将应用程序的菜单读到Treeview控件中,通用的,不管菜单有多少层
- 为什么用vb带的打包程序制作安的装程序,安装时总提示registering the file错误?
- 送分呀
- 组件注册时出现的错误(e:\xxx.dll was loaded,but the dllinstall entry point was not found)
- 救火啊,一个会者不难的简单问题,43分送(我最多只有这么多了)
- API:目录???
- 袁飞兄及各位大虾:快来看看!高分求教
- 求多元线性回归的算法?
- 用VB的OLE控件如果显示多页的WORD文档
是两个独立exe软件还是 一个软件中
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
Const Srccopy = &HCC0020
Const Swp_nomove = &H2
Const Swp_nosize = &H1
Const Flags = Swp_nomove Or Swp_nosize
Const hwnd_topmost = -1
Dim pos As POINTAPI
Private Sub Command11_Click()
Timer4.Interval = 10
SetWindowPos hwnd, hwnd_topmost, 0, 0, 0, 0, Flags
End Sub
Private Sub start()
Dim sx As Integer
Dim sy As Integer
GetCursorPos pos
sx = IIf(pos.X < 50 Or pos.X > 1000, IIf(pos.X < 50, 0, 950), pos.X - 50)
sy = IIf(pos.Y < 50 Or pos.Y > 600, IIf(pos.Y < 50, 0, 550), pos.Y - 50)
Caption = "坐标" & sx & "," & sy & " 放大镜程序"
StretchBlt Picture1.hdc, 0, 0, 200, 200, GetDC(0), sx, sy, 100, 100, Srccopy
End SubPrivate Sub Timer4_Timer()
start
End Sub
上面是代码,一点CLICK就执行放大镜程序,怎么做才可以再次点CLICK就停止放大镜程序啊
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
Const Srccopy = &HCC0020
Const Swp_nomove = &H2
Const Swp_nosize = &H1
Const Flags = Swp_nomove Or Swp_nosize
Const hwnd_topmost = -1
Dim pos As POINTAPIPrivate Sub Command11_Click()
If Command11.Caption = "放大" Then
Timer4.Enabled = True
Timer4.Interval = 10
SetWindowPos hwnd, hwnd_topmost, 0, 0, 0, 0, Flags
Command11.Caption = "停止"
ElseIf Command11.Caption = "停止" Then
Timer4.Enabled = False
Command11.Caption = "放大"
Picture1.Picture = LoadPicture("")
End If
End SubPrivate Sub start()
Dim sx As Integer
Dim sy As Integer
GetCursorPos pos
sx = IIf(pos.X < 50 Or pos.X > 1000, IIf(pos.X < 50, 0, 950), pos.X - 50)
sy = IIf(pos.Y < 50 Or pos.Y > 600, IIf(pos.Y < 50, 0, 550), pos.Y - 50)
Caption = "坐标" & sx & "," & sy & " 放大镜程序"
StretchBlt Picture1.hdc, 0, 0, 200, 200, GetDC(0), sx, sy, 100, 100, Srccopy
End Sub
Private Sub Timer4_Timer()
start
End Sub
再把click事件代码改成:
if command1.caption="开始" then
command1.caption="停止"
Timer4.Interval = 10
SetWindowPos hwnd, hwnd_topmost, 0, 0, 0, 0, Flags
else
unload me
end if
也谢谢Alzzl(果子林) ,你这样的话,一下就把程序全关闭了
多谢大家的帮助