vb里判断鼠标离开一个失去焦点的窗体的方法
想用VB写一个程序,实现有Form1和Form2两个窗体,Form2叠放在Form1上面,前面的叠放已经完成了,现在想让当鼠标移到Form2上时Form1显示,移出For...
想用VB写一个程序,实现有Form1和Form2两个窗体,Form2叠放在Form1上面,前面的叠放已经完成了,现在想让当鼠标移到Form2上时Form1显示,移出Form1时Form1隐藏,但整个过程中Form1都没有得到焦点,这样的效果能做吗?能的话要怎么做?
展开
2个回答
2013-08-09
展开全部
根据你的补充,特作如下改动。经调试,没有出现窗口标题栏一直在闪的现象。
即在timer控件内写入如下代码:
if GetForegroundWindow<> me.hwnd then
Me.SetFocus
end if
当然,之前你必须先声明
private Declare Function GetForegroundWindow Lib "User32" () As Long
即在timer控件内写入如下代码:
if GetForegroundWindow<> me.hwnd then
Me.SetFocus
end if
当然,之前你必须先声明
private Declare Function GetForegroundWindow Lib "User32" () As Long
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-09
展开全部
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Const WS_EX_TRANSPARENT As Long = &H20&
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
Dim Ret As Long
Ret = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
SetWindowLong Me.hwnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Me.hwnd, 0, 255, LWA_ALPHA
End Sub
是这个吗
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Const WS_EX_TRANSPARENT As Long = &H20&
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
Dim Ret As Long
Ret = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED Or WS_EX_TRANSPARENT
SetWindowLong Me.hwnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Me.hwnd, 0, 255, LWA_ALPHA
End Sub
是这个吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询