VB中怎样在TextBox中显示当前活动窗口标题

还有,怎样判断一个窗口是否处于活动状态.... 还有,怎样判断一个窗口是否处于活动状态. 展开
 我来答
victor1058
2006-03-25 · TA获得超过699个赞
知道大有可为答主
回答量:1285
采纳率:0%
帮助的人:1027万
展开全部
你需要使用到很多的API函数。
下面的是一个枚举所有正在运行窗口标题的例子。所有窗口标题会在LIST列表中显示。
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function EnableWindow& Lib "user32" (ByVal hWnd As Long, ByVal fEnable As Long)
Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long
Private Declare Function SendMessageA Lib "user32" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) 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 Declare Function getparent Lib "user32" Alias "GetParent" (ByVal hWnd As Long) As Long

Private Sub Command13_Click()
List1.Clear
Dim TN As String
wndow = GetWindow(Me.hWnd, 0)
While wndow <> 0
TN = Space(GetWindowTextLength(wndow) + 1)
If GetWindowText(wndow, TN, GetWindowTextLength(wndow) + 1) > 0 And Left(TN, Len(TN) - 1) <> Me.Caption Then List1.AddItem Left(TN, Len(TN) - 1)
wndow = GetWindow(wndow, 2)
Wend
End Sub

Private Sub Form_Load()
Command13_Click
End Sub
Bisn
2006-03-25 · TA获得超过905个赞
知道小有建树答主
回答量:746
采纳率:33%
帮助的人:410万
展开全部
text1.text=form1.caption
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式