首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

修改指定窗口标题解决思路

2012-02-02 
修改指定窗口标题已知我已经获取到一个应用程序标题,如“计算器”然后我想用VB来修改现在这个计算器的窗口名

修改指定窗口标题
已知我已经获取到一个应用程序标题,如“计算器”
然后我想用VB来修改现在这个计算器的窗口名称
请问改怎么做,有高手指点下。

[解决办法]
Const WM_SETTEXT = &HC
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 Sub Command1_Click()
SendMessage &H1099E, WM_SETTEXT, 0, ByVal "334455 "
End Sub

其中&H1099E是窗口句柄
[解决办法]
Option Explicit
Private Declare Function SetWindowText Lib "user32 " Alias "SetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function FindWindow Lib "user32 " Alias "FindWindowA " (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Command1_Click()
Dim Phwnd As Long
Phwnd = FindWindow(vbNullString, "Form1 ")
SetWindowText Phwnd, "123 "
End Sub


[解决办法]
Option Explicit
Private Declare Function SetWindowText Lib "user32 " Alias "SetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function FindWindow Lib "user32 " Alias "FindWindowA " (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Command1_Click()
Dim Phwnd As Long
Phwnd = FindWindow(vbNullString, "计算器 ")
SetWindowText Phwnd, "123 "
End Sub

热点排行