返回列表 上一主題 發帖

如何在TextBox1中顯示輸入法

本帖最後由 luhpro 於 2013-9-4 23:11 編輯

回復 1# sillykin
網路上找到的方法, 利用 SendKeys -
使用前必須先設定好輸入法的快速切換鍵 :
倉頡 Ctrl + Shift + 1
注音 Ctrl + Shift + 3 如右圖 :  

因為 TextBox 沒有類似 GotFocus 或是 Activate 之類的事件來實作剛進入時切換輸入法的動作,
這裡我透過各TextBox 的 MouseUp 事件來切換輸入法,
不過, 此法只能用於滑鼠點擊的方式來做切換 TextBox 的動作,
若是使用者使用 Tab 鍵來切換的話就只能切換是否為中文輸入狀態囉.
  1. Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  2.   'SendKeys ("^+0")  ' 可不用加此行, 因為我最初是設定切換英數的快速鍵為 Ctrl + Shift + 0 , 而這個已可由 TextBox1.IMEMode = fmIMEModeOff  來實現了.
  3. End Sub

  4. Private Sub TextBox2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  5.   SendKeys ("^+1")
  6. End Sub

  7. Private Sub TextBox3_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  8.   SendKeys ("^+3")
  9. End Sub

  10. Private Sub UserForm_Initialize()
  11.   TextBox1.IMEMode = fmIMEModeOff ' 英數
  12.   TextBox2.IMEMode = fmIMEModeOn  ' 倉頡
  13.   TextBox3.IMEMode = fmIMEModeOn  ' 注音
  14. End Sub
複製代碼
如何在TextBox1中顯示輸入法-a.zip (9.66 KB)
1

評分人數

    • GBKEE: 精品文章金錢 + 5

TOP

        靜思自在 : 修行要繫緣修心,藉事練心,隨處養心。
返回列表 上一主題