1、将scroll-view的scroll-y属性设置为false,这样可以禁用scroll-view的纵向滑动功能,避免滑动条出现。
2、在input组件绑定focus和blur事件,当input组件被聚焦时,将scroll-view组件滚动到输入框所在的位置,当input组件失去聚焦时,将scroll-top值设置为0,这样可以让页面回到最顶部。
无论用VB、Delphi、甚至VC++这个功能都得调用 *** 作系统的Win API函数Hook来实现。
方法是用Hook来勾住系统捕捉到的键盘事件,当发现用户按下的是F12时阻止键盘消息传递来实现F12不响应的。
以下钩子程序能阻止除ctrl alt del以外的所有键盘消息
Option Explicit
Private Declare Function CallNextHookEx Lib "user32 " _
(ByVal hHook As Long, _
ByVal nCode As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SetWindowsHookEx Lib "user32 " _
Alias "SetWindowsHookExA " _
(ByVal idHook As Long, _
ByVal lpfn As Long, _
ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32 " _
(ByVal hHook As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32 " _
Alias "RtlMoveMemory " _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)
Private Type PKBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Private Const WM_KEYDOWN = &H100
Private Const WM_SYSKEYDOWN = &H104
Private Const WM_KEYUP = &H101
Private Const WM_SYSKEYUP = &H105
Private Const VK_LWIN = &H5B
Private Const VK_RWIN = &H5C
Private Const HC_ACTION = 0
Private Const WH_KEYBOARD_LL = 13
Private lngHook As Long
'使用底层KeyboardHook拦截按键消息
Public Function LowLevelKeyboardProc(ByVal nCode As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim blnHook As Boolean
Dim p As PKBDLLHOOKSTRUCT
If nCode = HC_ACTION Then
Select Case wParam
Case WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP
Call CopyMemory(p, ByVal lParam, Len(p))
If pvkCode = VK_LWIN Or pvkCode = VK_RWIN Then '按下了左/右Win键
blnHook = True
End If
Case Else
'do nothing
End Select
End If
If blnHook Then
LowLevelKeyboardProc = 1
Else
Call CallNextHookEx(WH_KEYBOARD_LL, nCode, wParam, lParam)
End If
End Function
Public Sub HooK()
lngHook = SetWindowsHookEx(WH_KEYBOARD_LL, _
AddressOf LowLevelKeyboardProc, _
ApphInstance, _
0)
End Sub
Public Sub UnHooK()
Call UnhookWindowsHookEx(lngHook)
End Sub
'
'把以下程序粘贴到窗体中
'
Private Sub Form_Load()
Hook
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHook
End Sub
我们在进入某个页面时,希望可以定位到某一个Input输入框中,并且实现软键盘自动d出,在小程序中如何实现呢?
这里我们主要使用到属性是Input控件中的focus属性,我们将focus的值设为 true是,自动获得焦点同时d起键盘
这里需要用到wxhideKeyboard()方法,比如我们想实现用户输入123后自动收起键盘,实现方式如下
wxml文件中
js文件中
好啦,以上就是我本次分享的全部内容啦,如果你觉得我的文章对你有一丢丢帮助,那么请不要吝啬你的赞
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)