VB6.0怎么让另外一个程序的某个窗体获得焦点
就比如说.当我点下一个command之后..焦点会到我打开的系统记事本里.然后输入某某东西..求各位大侠帮帮忙,小弟先行谢过....
就比如说.当我点下一个command之后..焦点会到我打开的系统记事本里.然后输入某某东西..求各位大侠帮帮忙,小弟先行谢过.
展开
2个回答
展开全部
Private Declare Function FindWindow Lib "user32" Alias "简团FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC
'//声明
Private Sub Command4_Click() '向记事本写入文字
Dim hwnd As Long, Thwnd As Long
Shell "判燃notepad.exe", 2 '打开一个记事本,将它最小化
hwnd = FindWindow("Notepad", "无标题 - 记事本") '得到记事本句柄
Thwnd = FindWindowEx(hwnd, 0, "Edit", vbNullString) '得到记拦冲橘事本句柄(就是我们写字的那里)
SendMessage Thwnd, WM_SETTEXT, 0, ByVal SS '向记事本写入文字
setfucos hwnd
End Sub
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC
'//声明
Private Sub Command4_Click() '向记事本写入文字
Dim hwnd As Long, Thwnd As Long
Shell "判燃notepad.exe", 2 '打开一个记事本,将它最小化
hwnd = FindWindow("Notepad", "无标题 - 记事本") '得到记事本句柄
Thwnd = FindWindowEx(hwnd, 0, "Edit", vbNullString) '得到记拦冲橘事本句柄(就是我们写字的那里)
SendMessage Thwnd, WM_SETTEXT, 0, ByVal SS '向记事本写入文字
setfucos hwnd
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询