# API问题-烦请小吴看一下

Posted by BB on August 30, 1998 at 23:22:11:

小吴(或者不认识的高手)您好 :
在您收集的文章中有一篇教到使用以下方法可以代替SendKeys {TAB}
但是我试用的结果会出现执行期错误91 没有设定物件变数或with区块变数!
经查验结果问题好像出在 Screen.ActiveControl.hwnd !!可否有解决之道
呢?谢谢!

Private Declare Function GetNextDlgTabItem Lib "user32" (ByVal hDlg As Long, _
ByVal hCtl As Long, ByVal bPrevious As Long) As Long
Private Declare Function SetDlgFocus Lib "user32" Alias "SetFocus" _
(ByVal hwnd As Long) As Long

'移到下一个可Focus的Control
Private Sub NextDlg()
Dim hwnd5 As Long
hwnd5 = GetNextDlgTabItem(Me.hwnd, Screen.ActiveControl.hwnd, 1)
Call SetDlgFocus(hwnd5)
End Sub

'移到上一个可Focus的Control
Private Sub PrevDlg()
Dim hwnd5 As Long
hwnd5 = GetNextDlgTabItem(Me.hwnd, Screen.ActiveControl.hwnd, 0)
Call SetDlgFocus(hwnd5)
End Sub

Follow Ups:

- Re: API问题-烦请小吴看一下 cww 08:56:19 8/31/98 (0)