怎样获得系统当前焦点文本框内的内容?分已经不多了,帮帮忙

sheerfish999 2003-11-07 12:28:53
我的一个程序,需要获得系统即时状态下焦点所在的文本框里的内容,用什么样的方法呢?
...全文
34 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
AsiaContennent 2003-11-13
  • 打赏
  • 举报
回复
当前窗口名称.文本框名称.Text
wingsoft 2003-11-13
  • 打赏
  • 举报
回复
windowformpoint取得MOUSE所在处的句柄,getWindowlong看是不是TEXTBOX,是的话,getwindowtext
sheerfish999 2003-11-13
  • 打赏
  • 举报
回复
还有什么好的意见?
sheerfish999 2003-11-08
  • 打赏
  • 举报
回复
谢谢你们了,可是我想要的是获得系统焦点的文本内容,不是程序本身的呀。有没有相关api的呢?
hhjjhjhj 2003-11-08
  • 打赏
  • 举报
回复
窗体中放一个Text1,timer1,Command1,点击Command1后马上把焦点移到Text1,试试
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 2000
End Sub

Private Sub Timer1_Timer()
MsgBox ActiveControl.Text
Timer1.Enabled = False
End Sub
sheerfish999 2003-11-08
  • 打赏
  • 举报
回复
自己up
软侠 2003-11-08
  • 打赏
  • 举报
回复
各位大虾,小第刚学VB(才半个月),但我有一个建议,你可以用一个查找当前系统中获得焦点的窗口的API函数,然后再用楼上houwei(飞浪)给出的那个获得问本的API获取文本就可以了,不知是不是对的,请高手指教.
flc 2003-11-07
  • 打赏
  • 举报
回复
关注
hhjjhjhj 2003-11-07
  • 打赏
  • 举报
回复
ActiveControl.Text
houwei 2003-11-07
  • 打赏
  • 举报
回复
Private Declare Function GetFocus Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Sub Form_click()
Form2.Show
End Sub

Private Sub Timer1_Timer()
Dim lnghWnd As Long
Dim strText As String * 1000
Dim lngLenth As Long
Dim lngReturn As Long
lnghWnd = GetFocus()
lngLenth = 1000
lngLenth = GetWindowText(lnghWnd, strText, lngLenth)
Text1.Text = lnghWnd
Text2.Text = Left(strText, lngLenth)
End Sub
这种方法只能获得,本进程内的焦点控件的文本
sheerfish999 2003-11-07
  • 打赏
  • 举报
回复
请问hhjjhjhj(大头),“ActiveControl.Text”是什么意思呀?

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧