假如你只是想“点击开始按键后不弹出开始菜单”
那可以用CreateWindowEx创建按键
使创建的按键刚好遮住了开始按键如果你想按Win键不弹出开始菜单
那只有试试全局钩子了
但VB不能写Win32 dll
只有用其他语言写了
创建按键的例子:
Const WS_CHILD = &H40000000
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const SW_HIDE = 0
Const SW_NORMAL = 1
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim tWnd As Long, bWnd As Long, ncWnd As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim R As RECT
'Get the taskbar's window handle
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
'Get the start-button's window handle
bWnd = FindWindowEx(tWnd, ByVal 0&, "BUTTON", vbNullString)
'Get the start button's position
GetWindowRect bWnd, R
'Create a new button
ncWnd = CreateWindowEx(ByVal 0&, "BUTTON", "Hello !", WS_CHILD, 0, 0, R.Right - R.Left, R.Bottom - R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&)
'Show our button
ShowWindow ncWnd, SW_NORMAL
'Hide the start button
ShowWindow bWnd, SW_HIDE
End Sub
Private Sub Form_Unload(Cancel As Integer)
'show the start button
ShowWindow bWnd, SW_NORMAL
'destroy our button
DestroyWindow ncWnd
End Sub
那可以用CreateWindowEx创建按键
使创建的按键刚好遮住了开始按键如果你想按Win键不弹出开始菜单
那只有试试全局钩子了
但VB不能写Win32 dll
只有用其他语言写了
创建按键的例子:
Const WS_CHILD = &H40000000
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const SW_HIDE = 0
Const SW_NORMAL = 1
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim tWnd As Long, bWnd As Long, ncWnd As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim R As RECT
'Get the taskbar's window handle
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
'Get the start-button's window handle
bWnd = FindWindowEx(tWnd, ByVal 0&, "BUTTON", vbNullString)
'Get the start button's position
GetWindowRect bWnd, R
'Create a new button
ncWnd = CreateWindowEx(ByVal 0&, "BUTTON", "Hello !", WS_CHILD, 0, 0, R.Right - R.Left, R.Bottom - R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&)
'Show our button
ShowWindow ncWnd, SW_NORMAL
'Hide the start button
ShowWindow bWnd, SW_HIDE
End Sub
Private Sub Form_Unload(Cancel As Integer)
'show the start button
ShowWindow bWnd, SW_NORMAL
'destroy our button
DestroyWindow ncWnd
End Sub
解决方案 »
- 系统测试
- 求助:生成自增编号,却不更新?
- 求用VB实现FTP的的代码?
- 这个软件的功能如何用vb实现
- ◆局域网内服务器数据库的拷贝?◆
- 关于在ocx中添加属性
- playyuer 帮我看一下!找工作vb需达到怎样的水平(如:com,等)!在线等待!
- 当需要 do……case处理的事件很多时,如何提高处理的效率啊~(只用do……case处理)
- 请大家帮忙,关于CrystalReport8的问题,问题有点急,谢谢!!!
- vb可用sendkey对已知窗体发送信息,如何才能取得已知窗体的输出信息?
- 在一form中,有两个textbox控件,利用dao对一access数据库访问,如何将数据库中一个表的各项值显示在textbox中?谢谢
- 我也来提问!关于改变窗体默认标题栏和边框样式的问题!
再EnableWindow