VB 获取到窗口句柄怎么改写窗口的标题
4个回答
展开全部
API函数...
Private Declare Function SetWindowTextA Lib "user32" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Form_Load()
SetWindowTextA hwnd, "修改后的标题"
End Sub
----------------
标题改为1..........这样:SetWindowTextA hwnd, "1"
hwnd是记事本的句柄,后一参数是修改后的标题...
怎么用:
Private Declare Function SetWindowTextA Lib "user32" (ByVal hwnd As Long, ByVal lpString As String) As Long,把这行代码放到所有代码的最顶部去..也就是放在声明部分...
然后在程序中就可以直接使用了,SetWindowTextA中2个参数:hwnd是欲修改的句柄,lpString是修改后的标题
Private Declare Function SetWindowTextA Lib "user32" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Form_Load()
SetWindowTextA hwnd, "修改后的标题"
End Sub
----------------
标题改为1..........这样:SetWindowTextA hwnd, "1"
hwnd是记事本的句柄,后一参数是修改后的标题...
怎么用:
Private Declare Function SetWindowTextA Lib "user32" (ByVal hwnd As Long, ByVal lpString As String) As Long,把这行代码放到所有代码的最顶部去..也就是放在声明部分...
然后在程序中就可以直接使用了,SetWindowTextA中2个参数:hwnd是欲修改的句柄,lpString是修改后的标题
展开全部
SetWindowText
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
设置窗口的标题文字或控件的内容(在vb里使用:针对vb窗体,应使用caption或text属性)
【返回值】
Long,非零表示成功,零表示失败。会设置GetLastError
【其它】
【参数表】
hwnd ----------- Long,要设置文字的窗口的句柄
lpString ------- String,要设到hwnd窗口中的文字
注意要改变的窗口标题如果具有单独的句柄的话,一定要以标题的句柄作为参数
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
设置窗口的标题文字或控件的内容(在vb里使用:针对vb窗体,应使用caption或text属性)
【返回值】
Long,非零表示成功,零表示失败。会设置GetLastError
【其它】
【参数表】
hwnd ----------- Long,要设置文字的窗口的句柄
lpString ------- String,要设到hwnd窗口中的文字
注意要改变的窗口标题如果具有单独的句柄的话,一定要以标题的句柄作为参数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'以计算器为例
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
Shell "C:\WINDOWS\system32\calc.exe", 1
Dim hwnd As Long
hwnd = FindWindow("SciCalc", "计算器")
If hwnd = 0 Then Exit Sub
SetWindowText hwnd, "这里改成你想要的名字"
End Sub
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
Shell "C:\WINDOWS\system32\calc.exe", 1
Dim hwnd As Long
hwnd = FindWindow("SciCalc", "计算器")
If hwnd = 0 Then Exit Sub
SetWindowText hwnd, "这里改成你想要的名字"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
属性栏里面改
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询