用户登录  |  用户注册
首 页源码下载网络学院最新源码源码排行屏蔽广告
当前位置:新兴网络 > 网络学院 > 编程开发 > Visual Basic

VB SendMessage向其他程序窗口发送字符串消息实例

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2010-05-25 17:20:49

以下通过程序的标题来获取该窗口的句柄,然后通过SendMessage函数给该窗口句柄发送WM_SETTEXT消息。
VBScript code复制代码
'先创建一个文本文档,命名为: 1.txt

'     然后打开测试。。。
Private 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 Declare Function FindWindow _
                Lib "user32" _
                Alias "FindWindowA" (ByVal lpClassName As String, _
                                     ByVal lpWindowName As String) As Long
Private Declare Function GetDlgItem _
                Lib "user32" (ByVal hDlg As Long, _
                              ByVal nIDDlgItem As Long) As Long

Private Sub Command1_Click()
    Dim s               As String
    Dim FT_hWnd         As Long
    Dim ID_Control_hWnd As Long
    s = "你好"
    FT_hWnd = FindWindow(vbNullString, "1.txt - 记事本")

    If FT_hWnd = 0 Then
        MsgBox "False", vbInformation, "Title"
        End
    End If

    ID_Control_hWnd = GetDlgItem(FT_hWnd, &HF)
    SendMessage ID_Control_hWnd, WM_SETTEXT, 0, ByVal s

End Sub

Tags:VB SendMessage 字符串消息

作者:佚名
  • 好的评价 如果您觉得此文章好,就请您
      93%(13)
  • 差的评价 如果您觉得此文章差,就请您
      7%(1)

网络学院评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论