如果那个控件本来就是焦点,再用setfocus就会出错
解决方案 »
- 在VB中如何更改水晶报表的数据源
- 我想遍历SSTAB中第二个选项卡中的所有TEXTBOX控件,这个语句怎么写,在线等!谢谢!
- 关于数组!!1
- 怎样控制word文档里一个指定的图片不能被选定移动和移动?
- 看一下這個代碼可不可以更簡單
- 如何查看*.db(Paradox)的内容,如:QQ的聊天记录
- 用户权限,加分!
- 穷我所有给高手送分:vb连接access问题(急!急!)!
- WEBSERVER中定义的public class 在VB中怎么定义
- listview的多选问题.
- 求助:有没有人开发过背单词之类的小软件,有谁知道怎么利用金山词霸的的单词库啊!
- 如何动态绑定MSHFlexGrid控件?(在程序中,用代码。vb6)
Command1.SetFocus
End SubPrivate Sub Text1_GotFocus()
Text1.SetFocus
End Sub没问题的,你看上面的,它本来就有焦点,但是再用SetFocus,还是没有任何问题的如果你想知道焦点在哪个空件上面
Me.ActiveControl,就可以告诉你哪个空间有焦点了if Me.ActiveControl.name="你想知道的空件名称" then
debug.print "你这个空件已经有焦点了"
end if
哦,这样实现就可以了
MsgBox TypeName(Me.ActiveControl)
放在定时器里试试,应该可以的
在控件的getfocts中记录,在lostfoctus中去掉记录不就行了
MsgBox ctlinfocus(Text1)
End Sub
Function ctlinfocus(ByVal ctl As Control) As Boolean
ctlinfocus = False
If Me.ActiveControl.Name = ctl.Name Then ctlinfocus = True
End Function
Option ExplicitPrivate Sub Command1_Click()
Text1.SetFocus
Text1.SetFocus
Text1.SetFocus
Text1.SetFocus
Text1.SetFocus
End SubPrivate Sub Command2_Click()
Command1.SetFocus
End Sub
if ActiveControl.hWnd=yourcontrol.hWnd then
msgbox yourcontrol.name
endif对于没有句柄的控件,还是:
if ActiveControl.Name=yourcontrol.Name _
and ActiveControl.index=yourcontrol.index then
msgbox yourcontrol.name
endif另外,焦点只能移到可视的,并且Enabled 属性为 False 的窗体或控件。