我的软件很简单,就是嵌入一个页面。 1、我弄了一个类似QQ一样,鼠标离开就会缩上去的效果,但问题就出在忘软件上面打字的时候,打字的选择框总给软件覆盖了!就是软件总变为始终都在最顶部了,改如何解决这个问题啊? 2、就是软件最小化后,无法双击或者单击的还原上来哦,一缩小就无法挽回了!! 3、当软件关闭后,右下角任务栏的图标还不会自动消失,但鼠标一划过去,它就才消失了。 三个问题,麻烦高手帮忙帮忙,新来新手,分不多,请谅解!以后补上! 我是新手,请各位高手尽量给详细的办法哦,谢谢! 代码如下: Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2'
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End TypePrivate Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOP = 0
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
'
Private Const WM_NCLBUTTONDOWN = &HA1Private Sub Form_Load()'以下把程序放入System Tray====================================System Tray Begin
With nfIconData
.hwnd = Me.hwnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
'定义鼠标移动到托盘上时显示的Tip
.szTip = "工具" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
'=============================================================System Tray End
WebBrowser1.Navigate "http://www.baidu.com/"
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BorderStyle = 1
End Sub
Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.BorderStyle = 1
End Sub
Private Sub Label4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.BorderStyle = 1
End Sub
Private Sub Label1_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com/", "", "", 5
End SubPrivate Sub Label3_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 5
End SubPrivate Sub Label4_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 5
End SubPrivate Sub Label5_Click()
Me.Hide
End SubPrivate Sub Label7_Click()
End
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BorderStyle = 0
Label3.BorderStyle = 0
Label4.BorderStyle = 0
Label5.BorderStyle = 0
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
ShowWindow Me.hwnd, SW_RESTORE
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End SubPrivate Sub Timer1_Timer()
Call hideQQ
End SubSub hideQQ()
Dim p As POINTAPI
Dim f As RECT
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
GetCursorPos p '得到MOUSE位置
GetWindowRect Me.hwnd, f '得到窗体的位置
If Me.WindowState <> 1 Then
If p.X > f.Left And p.X < f.Right And p.Y > f.Top And p.Y < f.Bottom Then
'MOUSE 在窗体上
If Me.Top < 0 Then
Me.Top = -20
Me.Show
ElseIf Me.Left < 0 Then
Me.Left = -10
Me.Show
ElseIf Me.Left + Me.Width >= Screen.Width Then
Me.Left = Screen.Width - Me.Width + 10
Me.Show
End If
Else
If f.Top <= 4 Then
Me.Top = 280 - Me.Height
ElseIf f.Left <= 4 Then
Me.Left = 40 - Me.Width
ElseIf Me.Left + Me.Width >= Screen.Width - 4 Then
Me.Left = Screen.Width - 40
End If
End If
End If
End Sub
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2'
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End TypePrivate Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOP = 0
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
'
Private Const WM_NCLBUTTONDOWN = &HA1Private Sub Form_Load()'以下把程序放入System Tray====================================System Tray Begin
With nfIconData
.hwnd = Me.hwnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
'定义鼠标移动到托盘上时显示的Tip
.szTip = "工具" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
'=============================================================System Tray End
WebBrowser1.Navigate "http://www.baidu.com/"
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BorderStyle = 1
End Sub
Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.BorderStyle = 1
End Sub
Private Sub Label4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.BorderStyle = 1
End Sub
Private Sub Label1_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com/", "", "", 5
End SubPrivate Sub Label3_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 5
End SubPrivate Sub Label4_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 5
End SubPrivate Sub Label5_Click()
Me.Hide
End SubPrivate Sub Label7_Click()
End
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BorderStyle = 0
Label3.BorderStyle = 0
Label4.BorderStyle = 0
Label5.BorderStyle = 0
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
ShowWindow Me.hwnd, SW_RESTORE
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End SubPrivate Sub Timer1_Timer()
Call hideQQ
End SubSub hideQQ()
Dim p As POINTAPI
Dim f As RECT
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
GetCursorPos p '得到MOUSE位置
GetWindowRect Me.hwnd, f '得到窗体的位置
If Me.WindowState <> 1 Then
If p.X > f.Left And p.X < f.Right And p.Y > f.Top And p.Y < f.Bottom Then
'MOUSE 在窗体上
If Me.Top < 0 Then
Me.Top = -20
Me.Show
ElseIf Me.Left < 0 Then
Me.Left = -10
Me.Show
ElseIf Me.Left + Me.Width >= Screen.Width Then
Me.Left = Screen.Width - Me.Width + 10
Me.Show
End If
Else
If f.Top <= 4 Then
Me.Top = 280 - Me.Height
ElseIf f.Left <= 4 Then
Me.Left = 40 - Me.Width
ElseIf Me.Left + Me.Width >= Screen.Width - 4 Then
Me.Left = Screen.Width - 40
End If
End If
End If
End Sub
解决方案 »
- VB6引用了EXCEL 对象,打包。但给客户安装时候,却提示安装OFFICE ?
- 求vsflexgrid 这样的数据库实例?
- 请问:如何将gif动画显示到命令按钮上
- 一直没有解决的问题:怎样才能隐藏LISTVIEW的某个列,运行时用户不能拉出这个隐藏的列
- 如何用maskedit做一个IP的输入框,当输入"."的时候会自己跳到下一格
- mpg文件的播放时间
- 怎么用VB计算反三角函数的值?我是指用系统函数
- 用ADO技术的一个错误!!(不知错在那。好我是初学者,多多指教,万分感谢!)
- 在设计时不能添加DataRepoter是怎么回事?
- 请问做动态报表拿什么工具开发好?
- 初学者求学
- gsm串口测试问题!
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
'
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End TypePrivate Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOP = 0
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
'
Private Const WM_NCLBUTTONDOWN = &HA1
Const MAX_TOOLTIP As Integer = 64
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End TypeDim nfIconData As NOTIFYICONDATA
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const WM_MOUSEMOVE = &H200
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const SW_RESTORE = 9
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As LongPrivate Sub Form_Load()'以下把程序放入System Tray====================================System Tray Begin
With nfIconData
.hwnd = Me.hwnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
'定义鼠标移动到托盘上时显示的Tip
.szTip = "工具" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
'=============================================================System Tray End
'WebBrowser1.Navigate "http://www.baidu.com/"
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BorderStyle = 1
End Sub
Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.BorderStyle = 1
End Sub
Private Sub Label4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.BorderStyle = 1
End Sub
Private Sub Label1_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com/", "", "", 5
End SubPrivate Sub Label3_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 5
End SubPrivate Sub Label4_Click()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 5
End SubPrivate Sub Label5_Click()
Me.Hide
End SubPrivate Sub Label7_Click()
End
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BorderStyle = 0
Label3.BorderStyle = 0
Label4.BorderStyle = 0
Label5.BorderStyle = 0
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
ShowWindow Me.hwnd, SW_RESTORE
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End SubPrivate Sub Timer1_Timer()
Call hideQQ
End SubSub hideQQ()
Dim p As POINTAPI
Dim f As RECT
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
GetCursorPos p '得到MOUSE位置
GetWindowRect Me.hwnd, f '得到窗体的位置
If Me.WindowState <> 1 Then
If p.X > f.Left And p.X < f.Right And p.Y > f.Top And p.Y < f.Bottom Then
'MOUSE 在窗体上
If Me.Top < 0 Then
Me.Top = -20
Me.Show
ElseIf Me.Left < 0 Then
Me.Left = -10
Me.Show
ElseIf Me.Left + Me.Width >= Screen.Width Then
Me.Left = Screen.Width - Me.Width + 10
Me.Show
End If
Else
If f.Top <= 4 Then
Me.Top = 280 - Me.Height
ElseIf f.Left <= 4 Then
Me.Left = 40 - Me.Width
ElseIf Me.Left + Me.Width >= Screen.Width - 4 Then
Me.Left = Screen.Width - 40
End If
End If
End If
End Sub俺没做任何修改,只是补充了一些函数及常量声明,发现没有第三个问题。