msgbox "你显示的txt",vbokonly,"窗体的caption"
解决方案 »
- 关于MScomm控件问题,百思不得其解,请各位大神帮忙解惑。
- vb 调用 c# tlb 的疑难
- 调用excel功能完成打印
- 请问怎样用按钮控制,来改变SStab当前的选项卡
- Cnwanglin没分了
- 关于模糊查询!!!
- 水晶报表连接的问题,1.做了个*.rpt文件路径为d:\xfdk\*.mdb 2.程序中调用时是在app.path\*.mdb 3.为什么在用户用户哪里还要找设计用到
- 怎么样使textbox里的文本一行一行依次反显?
- vb中如何让combo1显示数据库中的所有表名?不用list属性!!!
- 写了一段VBA小程序,运行总是报错,看了半天也没看出来哪里错了,求指教。
- 请问data数据源和ado的有什么区别
- 1.如何让当鼠标移动到label1控件上时控件显示的文字是绿色,当移开时显示的是黄色!
The SetWindowText function changes the text of the specified window抯 title bar (if it has one). If the specified window is a control, the text of the control is changed.
The GetFocus function retrieves the handle of the window that has the keyboard focus, if the window is associated with the calling thread抯 message queue.
The GetFocus function retrieves the handle of the window that has the keyboard focus, if the window is associated with the calling thread抯 message queue.
那么在AAA_Click()事件中添加代码
AAA.Caption="你想要的内容!"
一定是用API的!!!!!不是本窗体!!!!!看清题目,要的是与句柄相关的!!!不是本程序的窗体,是任一窗体!!!怎么获得它的hDC?
获得了后怎么得到窗体的caption?
怎么改写caption?
解决后给开贴100分!!!
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
说明
取得一个窗体的标题(caption)文字,或者一个控件的内容(在vb里使用:使用vb窗体或控件的caption或text属性)
返回值
Long,复制到lpString的字串长度;不包括空中止字符。会设置GetLastError
参数表
参数 类型及说明
hwnd Long,欲获取文字的那个窗口的句柄
lpString String,预定义的一个缓冲区,至少有cch+1个字符大小;随同窗口文字载入
cch Long,lpString缓冲区的长度
注解
不能用它从另一个应用程序的编辑控件中获取文字
====================================================================SetWindowText VB声明
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 GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Long
说明
获得前台窗口的句柄。这里的“前台窗口”是指前台应用程序的活动窗口
返回值
Long,前台窗口的句柄
注解
windows nt支持多个桌面,它们相互间是独立的。每个桌面都有自己的前台窗口
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 LongPrivate Sub Command1_Click()
Dim winHwnd As Long
winHwnd = FindWindow(vbNullString, Text1.Text)
If winHwnd <> 0 Then
SetWindowText winHwnd, Text2.Text
Else
MsgBox "并未开启" & Text1.Text
End If
End SubPrivate Sub Form_Load()
Text1.Text = "Form1"
Text2.Text = "改了!"
End Sub
我是要可以更改系统里任何一个窗!!!!
Option ExplicitPrivate Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As LongPrivate Type POINTAPI
x As Long
y As Long
End TypeDim myCursor As POINTAPI'再点击按钮后,将鼠标移到你想要改的窗体上
'看看标题栏里的变化吧!!
Private Sub Command1_Click()
Timer1.Enabled = True
End SubPrivate Sub Form_Load()
Timer1.Enabled = False
End SubPrivate Sub Timer1_Timer()
Dim myhWnd As Long
Dim strName As String * 100
Dim myCh As Long GetCursorPos myCursor
myhWnd = WindowFromPoint(myCursor.x, myCursor.y)
myCh = GetWindowText(myhWnd, strName, 100)
'Print Left(strName, myCh)
SetWindowText myhWnd, "改!!!!!!!!!!!"
End Sub
哎呀,连这个窗体都改了!!!