我想将一串字符逐个逐个的在文本框中输出,我用一个timer控件,然后在timer事件中控制text1.text=text1.text+"待输出的字符",但是屏幕会有些闪烁。
我知道如果是输出英文字符的话,可以用sendkeys可以模拟敲键盘,那么,如果是中文的话,是不是也有api函数可以实现这个功能呢?谢谢!

解决方案 »

  1.   

    中文那么多的同音字,怎么保证输入的就是你想要的?一个字一个字的传给text1就可以啊,不用什么模拟按键了。
      

  2.   

    不要用Time,Text不是有个Change事件吗?
    试试。
      

  3.   

    请问rappercn(rapper),如何实现" 一个字一个字的传给text1"阿
      

  4.   

    字符串我已经准备好了,比方说字符串str=“中文那么多的同音字,怎么保证输入的就是你想要的?”,现在我要把str逐个逐个的输到文本框中,让人感觉好想是人工敲进去的(事实上,这是数据库中杜取出来的)
      

  5.   

    ‘这是VC做的一个动态连接库
    include <windows.h>
    #include <ole2.h>char _stdcall MidAsc(BSTR str,int n)
    {  
    LPSTR pA;
    pA=(LPSTR)str;
    return *(pA+n-1);
    }int _stdcall StrLen(BSTR str)
    {   
    return strlen((LPCSTR)str);
    }’这是VB程序,API你自己声明,还有动态连接库的声明
    Option Explicit Const WM_CHAR = &H102
    Private Sub Command1_Click()
        Timer1.Enabled = True
    End SubPrivate Sub Form_Load()
      SetCurrentDirectory (App.Path)
    End SubPrivate Sub Timer1_Timer()
      Dim hWnd As Long
      Dim FormThreadID As Long
      Dim CWndThreadID As Long
      
      hWnd = GetForegroundWindow()
      If hWnd = Me.hWnd Then Exit Sub
      
      FormThreadID = GetCurrentThreadId()
      CWndThreadID = GetWindowThreadProcessId(hWnd, 0)
      
      AttachThreadInput CWndThreadID, FormThreadID, True
      hWnd = GetFocus()
      AttachThreadInput CWndThreadID, FormThreadID, False
      
      If hWnd <= 0 Then Exit Sub
      
      Dim i As Integer
      Dim lAsc As Long
      Text4 = ""
      For i = 1 To Len(Text1)
        lAsc = MidAsc(Text1, i) And &HFF
        Text4 = Text4 + str(i) + "-" + str(lAsc) + "-" + str(Asc(Mid(Text1, i, 1))) + vbCrLf
        PostMessage hWnd, WM_CHAR, Asc(Mid(Text1, i, 1)), 0
        'PostMessage hWnd, WM_CHAR, lAsc, 0
      Next i
      
      Timer1.Enabled = False
    End Sub
      

  6.   

    本问题已解决,原来sendkeys可以发汉字,参与过的都来几分吧!