กระทู้เก่าบอร์ด อ.สุภาพ ไชยา
277 2
URL.หัวข้อ /
URL
ถามต่อจากคำถามที่ 1536 ?
ผมได้เข้าไปในเว็บ
ได้ copy code แต่ไม่ทราบว่าจะนำไปใช้งานอย่างไร
ขอให้อ.ช่วยแนะนำด้วยครับ ขอบคุณครับ
'This example was created by Kirill V. Rodionov
'This program needs a Command Button, named Command1
Private Const KL_NAMELENGTH As Long = 9
Private Const HKL_NEXT As Long = 1
Private Const HKL_PREV As Long = 0
Private Declare Function ActivateKeyboardLayout Lib "user32" ( _
ByVal HKL As Long, _
ByVal Flags 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 Sub Command1_Click()
Dim lngCurrent_HKL As Long
Dim strCurrent_Buffer As String
Dim lngSwitched_HKL As Long
Dim strSwitched_Buffer As String
'Retrieves current handle to the keyboard layout
lngCurrent_HKL = GetKeyboardLayout(0)
'creates a buffers
strCurrent_Buffer = String(KL_NAMELENGTH - 1, 0)
strSwitched_Buffer = String(KL_NAMELENGTH - 1, 0)
'Retrieves current name of the active keyboard layout
GetKeyboardLayoutName strCurrent_Buffer
'Switches to the next keyboard layout
ActivateKeyboardLayout HKL_NEXT, 0
'Retrieves "switched" handle to the keyboard layout
lngSwitched_HKL = GetKeyboardLayout(0)
'Retrieves "switched" name of the active keyboard layout
GetKeyboardLayoutName strSwitched_Buffer
MsgBox "Keyboard layout was switched" & vbCrLf & "from " & strCurrent_Buffer _
& " to " & strSwitched_Buffer
'Returns to the initial keyboard layout
ActivateKeyboardLayout lngCurrentHKL, 0
End Sub
ได้ copy code แต่ไม่ทราบว่าจะนำไปใช้งานอย่างไร
ขอให้อ.ช่วยแนะนำด้วยครับ ขอบคุณครับ
'This example was created by Kirill V. Rodionov
'This program needs a Command Button, named Command1
Private Const KL_NAMELENGTH As Long = 9
Private Const HKL_NEXT As Long = 1
Private Const HKL_PREV As Long = 0
Private Declare Function ActivateKeyboardLayout Lib "user32" ( _
ByVal HKL As Long, _
ByVal Flags 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 Sub Command1_Click()
Dim lngCurrent_HKL As Long
Dim strCurrent_Buffer As String
Dim lngSwitched_HKL As Long
Dim strSwitched_Buffer As String
'Retrieves current handle to the keyboard layout
lngCurrent_HKL = GetKeyboardLayout(0)
'creates a buffers
strCurrent_Buffer = String(KL_NAMELENGTH - 1, 0)
strSwitched_Buffer = String(KL_NAMELENGTH - 1, 0)
'Retrieves current name of the active keyboard layout
GetKeyboardLayoutName strCurrent_Buffer
'Switches to the next keyboard layout
ActivateKeyboardLayout HKL_NEXT, 0
'Retrieves "switched" handle to the keyboard layout
lngSwitched_HKL = GetKeyboardLayout(0)
'Retrieves "switched" name of the active keyboard layout
GetKeyboardLayoutName strSwitched_Buffer
MsgBox "Keyboard layout was switched" & vbCrLf & "from " & strCurrent_Buffer _
& " to " & strSwitched_Buffer
'Returns to the initial keyboard layout
ActivateKeyboardLayout lngCurrentHKL, 0
End Sub
2 Reply in this Topic. Dispaly 1 pages and you are on page number 1
1 @R03561
ผมลองเอา code นี้ไปใช้ร่วมกับ timer ก็ได้ผลครับ ลองดู
2 @R03564
ขอบคุณมากครับ ใช้งานได้ดีเลยครับ
Time: 0.1523s