打开一个窗体的放大镜,然后将该窗体最小化,
当桌面上除放大镜再没有其它窗体时,点击任务栏上的窗体(打开为最大化),放大镜却跑到窗体后面了,
有没有办法让放大镜始终在最前面?放大镜代码如下:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End TypeConst Srccopy = &HCC0020
Const Swp_nomove = &H2
Const Swp_nosize = &H1
Const Flags = Swp_nomove Or Swp_nosize
Const hwnd_topmost = -1Private 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 GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As LongPrivate 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 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 Long) As LongDim pos As POINTAPI
Dim i As Long
Dim sx As Long
Dim sy As Long
Private Sub Form_Load()
setwindow
i = 2
sx = 100
sy = 100
End Sub
Private Sub Form_Click() '鼠标单击窗体
Timer1.Interval = 0
Me.Height = 3000
Me.Width = 3000
sx = 100
sy = 100
setwindow
Timer1.Interval = 50
End Sub
Private Sub setwindow()
SetWindowPos hWnd, hwnd_topmost, 0, 0, 0, 0, Flags
Dim hr&, dl&
Dim usew&, useh&
usew& = Me.Width / Screen.TwipsPerPixelX
useh& = Me.Height / Screen.TwipsPerPixelY
hr& = CreateEllipticRgn(0, 0, usew, useh)
dl& = SetWindowRgn(Me.hWnd, hr, True)
End SubPrivate Sub Timer1_Timer() '窗体放大效果
Dim wx As Integer
Dim wy As Integer
GetCursorPos pos
wx = IIf(pos.x < 50 Or pos.x > 800, IIf(pos.x < 50, 0, 800), pos.x - 50)
wy = IIf(pos.y < 20 Or pos.y > 800, IIf(pos.y < 20, 0, 800), pos.y - 20)
Caption = " 坐标" & wx & "," & wy & "放大倍数=" & i
StretchBlt hdc, 0, 0, sx * i, sy * i, GetDC(0), wx, wy, sx, sy, Srccopy
End SubPrivate Sub one_Click() '放大1倍
Timer1.Interval = 0
i = 1
Timer1.Interval = 50
End SubPrivate Sub onewin_Click() '窗口大小
Timer1.Interval = 0
Me.Height = 3000
Me.Width = 3000
sx = 100
sy = 100
setwindow
Timer1.Interval = 50
End SubPrivate Sub threewin_Click() '窗口大小
Timer1.Interval = 0
Me.Height = 3000 * 3
Me.Width = 3000 * 3
sx = 300
sy = 300
setwindow
Timer1.Interval = 50
End SubPrivate Sub two_Click() '放大2倍
Timer1.Interval = 0
i = 2
Timer1.Interval = 50
End SubPrivate Sub twowin_Click() '窗口大小
Timer1.Interval = 0
Me.Height = 3000 * 2
Me.Width = 3000 * 2
sx = 200
sy = 200
SetWindowPos hWnd, hwnd_topmost, 0, 0, 0, 0, Flags
Dim hr&, dl&
Dim usew&, useh&
usew& = Me.Width / Screen.TwipsPerPixelX
useh& = Me.Height / Screen.TwipsPerPixelY
hr& = CreateEllipticRgn(0, 0, usew, useh)
dl& = SetWindowRgn(Me.hWnd, hr, True)
Timer1.Interval = 50
End SubPrivate Sub three_Click() '放大3倍
Timer1.Interval = 0
i = 3
Timer1.Interval = 50
End SubPrivate Sub four_Click() '放大4倍
Timer1.Interval = 0
i = 4
Timer1.Interval = 50
End SubPrivate Sub exit_Click()
End
End Sub
当桌面上除放大镜再没有其它窗体时,点击任务栏上的窗体(打开为最大化),放大镜却跑到窗体后面了,
有没有办法让放大镜始终在最前面?放大镜代码如下:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End TypeConst Srccopy = &HCC0020
Const Swp_nomove = &H2
Const Swp_nosize = &H1
Const Flags = Swp_nomove Or Swp_nosize
Const hwnd_topmost = -1Private 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 GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As LongPrivate 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 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 Long) As LongDim pos As POINTAPI
Dim i As Long
Dim sx As Long
Dim sy As Long
Private Sub Form_Load()
setwindow
i = 2
sx = 100
sy = 100
End Sub
Private Sub Form_Click() '鼠标单击窗体
Timer1.Interval = 0
Me.Height = 3000
Me.Width = 3000
sx = 100
sy = 100
setwindow
Timer1.Interval = 50
End Sub
Private Sub setwindow()
SetWindowPos hWnd, hwnd_topmost, 0, 0, 0, 0, Flags
Dim hr&, dl&
Dim usew&, useh&
usew& = Me.Width / Screen.TwipsPerPixelX
useh& = Me.Height / Screen.TwipsPerPixelY
hr& = CreateEllipticRgn(0, 0, usew, useh)
dl& = SetWindowRgn(Me.hWnd, hr, True)
End SubPrivate Sub Timer1_Timer() '窗体放大效果
Dim wx As Integer
Dim wy As Integer
GetCursorPos pos
wx = IIf(pos.x < 50 Or pos.x > 800, IIf(pos.x < 50, 0, 800), pos.x - 50)
wy = IIf(pos.y < 20 Or pos.y > 800, IIf(pos.y < 20, 0, 800), pos.y - 20)
Caption = " 坐标" & wx & "," & wy & "放大倍数=" & i
StretchBlt hdc, 0, 0, sx * i, sy * i, GetDC(0), wx, wy, sx, sy, Srccopy
End SubPrivate Sub one_Click() '放大1倍
Timer1.Interval = 0
i = 1
Timer1.Interval = 50
End SubPrivate Sub onewin_Click() '窗口大小
Timer1.Interval = 0
Me.Height = 3000
Me.Width = 3000
sx = 100
sy = 100
setwindow
Timer1.Interval = 50
End SubPrivate Sub threewin_Click() '窗口大小
Timer1.Interval = 0
Me.Height = 3000 * 3
Me.Width = 3000 * 3
sx = 300
sy = 300
setwindow
Timer1.Interval = 50
End SubPrivate Sub two_Click() '放大2倍
Timer1.Interval = 0
i = 2
Timer1.Interval = 50
End SubPrivate Sub twowin_Click() '窗口大小
Timer1.Interval = 0
Me.Height = 3000 * 2
Me.Width = 3000 * 2
sx = 200
sy = 200
SetWindowPos hWnd, hwnd_topmost, 0, 0, 0, 0, Flags
Dim hr&, dl&
Dim usew&, useh&
usew& = Me.Width / Screen.TwipsPerPixelX
useh& = Me.Height / Screen.TwipsPerPixelY
hr& = CreateEllipticRgn(0, 0, usew, useh)
dl& = SetWindowRgn(Me.hWnd, hr, True)
Timer1.Interval = 50
End SubPrivate Sub three_Click() '放大3倍
Timer1.Interval = 0
i = 3
Timer1.Interval = 50
End SubPrivate Sub four_Click() '放大4倍
Timer1.Interval = 0
i = 4
Timer1.Interval = 50
End SubPrivate Sub exit_Click()
End
End Sub
解决方案 »
- 怎么能一条一条的操作表的纪录?
- 请问我想将一个表中的一条数据导到另一个表中,两个表的字段一样,请问怎么做最方便?效率最高呢?
- 如果将treeview控件中指定的两节点位置互换(连子节点)
- 利用MSComm控件点对点串行传送数据
- 为什么VB加载时,有些工程中引用的控件,不能加载上
- 关于硬盘格式化问题!!!
- 急!如何把字符串转换成整数
- 急:如何实现FlexGrid表格的删除功能
- 【求助】怎么读写这样的ini文件?
- 小弟的软件,给个意见!! http://www.csdn.net/cnshare/soft/12/12416.shtm 随便散分(100)
- 怎么解开DLL文件看内部是怎么写的?
- 急问:VB检索ORACLE数据的问题
别忘了加时间控件Timer:属性Interval=600
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, _
ByVal bInvert As Long) As LongPrivate Sub Form_Load()
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
Call FlashWindow(hwnd, 1)
If Form1.Caption = "闪烁标题栏" Then
Form1.Caption = "闪烁标题栏 "
Else
Form1.Caption = "闪烁标题栏"
End If
End Sub