谢谢~!!!
解决方案 »
- 不寻常的窗体问题,谁帮帮忙?
- 帮朋友做MIS,不知用VB6.0还是VB.NET哪个好,大家给出个主意
- 如何写非1433端口的SQL SERVER的ADO数据库连接串?
- 过几天需要发布软件,需要ftp空间,大该学要60mb,用一个星期就可以拉!!请帮帮忙!
- VB最后生成了可执行EXE,如何能使在任何机子上都可以运行?
- 有人知道网上股票软件是怎么开发的吗? 用的什么机制实现三层??不是COM+吧?
- === 请问,如何绑定DATAGRID和记录集 ? ===
- 怎样在进程栏中隐藏自己的程序。
- (sqlserver)哪位会写这样的存储过程:输入的参数是一个整数n,然后从纪录集rs中随机返回n条纪录?我现在要做的是一个随机的存储过程!!!
- 修改属性里面的内容?
- 关于mshflexgrid,在线等...急!!!!!!!!
- 低级问题,能把所有的VB6。0的快捷键公布一下吗?
【VB声明】
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long【别名】
FindWindowA【说明】
寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题) 【返回值】
Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError 【备注】
很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数
示例
Dim hw& , cnt&
Dim rttitle As String * 256
hw& = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
cnt = GetWindowText(hw& , rttitle, 255)
MsgBox Left$(rttitle, cnt), 0, "RTMain title"【参数表】
lpClassName ---- String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类 lpWindowName --- String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题例子:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub