msgbox "你显示的txt",vbokonly,"窗体的caption"

解决方案 »

  1.   

    呵呵,你可以用api函数的
    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.
      

  2.   

    假如窗体或者控件的名字是AAA
    那么在AAA_Click()事件中添加代码
    AAA.Caption="你想要的内容!"
      

  3.   

    算了!!!
    一定是用API的!!!!!不是本窗体!!!!!看清题目,要的是与句柄相关的!!!不是本程序的窗体,是任一窗体!!!怎么获得它的hDC?
    获得了后怎么得到窗体的caption?
    怎么改写caption?
    解决后给开贴100分!!!
      

  4.   

    GetWindowText VB声明 
    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窗口中的文字 
      

  5.   

    GetForegroundWindow VB声明 
    Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Long 
    说明 
    获得前台窗口的句柄。这里的“前台窗口”是指前台应用程序的活动窗口 
    返回值 
    Long,前台窗口的句柄 
    注解 
    windows nt支持多个桌面,它们相互间是独立的。每个桌面都有自己的前台窗口
     
      

  6.   

    一百分 可要算数呀
    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
      

  7.   

    楼上,不是这样吧?我要是也想把IE改了呢?SetWindowText:设置窗口的标题文字或控件的内容(在vb里使用:针对vb窗体,应使用caption或text属性)只对VB的窗体有效吧?
    我是要可以更改系统里任何一个窗!!!!
      

  8.   

    我想这样可以了吧?
    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
    哎呀,连这个窗体都改了!!!