⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 输入法控制.frm

📁 个人VB学习源码精选,自己学习时的一些编程小程序,希望对大家有帮助
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.ComboBox Combo1 
      Height          =   300
      Left            =   675
      TabIndex        =   1
      Text            =   "Combo1"
      Top             =   495
      Width           =   2355
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   285
      Left            =   1440
      TabIndex        =   0
      Top             =   1710
      Width           =   870
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, lpList As Long) As Long
Private Declare Function ImmGetDescription Lib "imm32.dll" Alias "ImmGetDescriptionA" (ByVal HKL As Long, ByVal lpsz As String, ByVal uBufLen As Long) As Long
Private Declare Function ImmIsIME Lib "imm32.dll" (ByVal HKL As Long) As Long
Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long
Private Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal flags As Long) As Long
Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal HKL As Long, ByVal flags As Long) As Long
Private Const KLF_REORDER = &H8
Private NoOfKbdLayout As Long, i As Long, j As Long
Private hCurKbdLayout As Long
Private Hkb(24) As Long
Private BuffLen As Long
Private Buff As String
Private RetStr As String
Private RetCount As Long
Private Kln As String

Private Sub Command1_Click()
    If Combo1.ListIndex = -1 Then
        MsgBox "请选择一种输入法"
        Exit Sub
    End If
    Kln = String(8, vbNullChar)
    ActivateKeyboardLayout Hkb(Combo1.ListIndex), 0
    res = GetKeyboardLayoutName(Kln)
    res = LoadKeyboardLayout(Kln, KLF_REORDER)
    ActivateKeyboardLayout hCurKbdLayout, 0
End Sub

Private Sub Form_Load()
    Buff = String(255#, vbNullChar)
    hCurKbdLayout = GetKeyboardLayout(0)
    NoOfKbdLayout = GetKeyboardLayoutList(25, Hkb(0))
    For i = 1 To NoOfKbdLayout
        If ImmIsIME(Hkb(i - 1)) = 1 Then
            BuffLen = 255
            RetCount = ImmGetDescription(Hkb(i - 1), Buff, BuffLen)
            RetStr = Left(Buff, RetCount)
            Combo1.AddItem RetStr
        Else
            RetStr = "English (American)"
            Combo1.AddItem RetStr
        End If
    Next i
    ActivateKeyboardLayout hCurKbdLayout, 0
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -