【分享成果,随喜正能量】以大慈为所住,给一切众生快乐,观众生心与菩萨心平等平等。以大悲为住处,不轻末学,善根成熟了他会发心,将来也能成佛。舍有为而不执著无为,住无为而不舍有为,有为无为平等。慈悲喜舍四无量心是菩萨住处。。
跟我学VBA,我这里专注VBA, 授人以渔。我98年开始,从源码接触VBA已经20余年了,随着年龄的增长,越来越觉得有必要把这项技能传递给需要这项技术的职场人员。希望职场和数据打交道的朋友,都来学习VBA,利用VBA,起码可以提高自己的工作效率,可以有时间多陪陪父母,多陪陪家人,何乐而不为呢?我的教程一共九套,从入门开始一直讲到程序的分发,是学习利用VBA的实用教程。这份API资料是随高级教程赠送的.
这讲我们继续学习64位Office API声明语句第110讲,这些内容是MS的权威资料,看似枯燥,但对于想学习API函数的朋友是非常有用的。
当学员学习到高级阶段,如果引用API,这个资料可以直接查到64位写法。大多数情况下我们是将低版本的程序文件升级到高版本,这时您就不必为如下的错误提示所困扰了:
' ********************************************************************
' IMM.H - Input Method Manager definitions
'
' Copyright (c) 1993-1995 Microsoft Corporation
' ********************************************************************
Const VK_PROCESSKEY = &HE5
Type COMPOSITIONFORM
dwStyle As Long
ptCurrentPos As POINTAPI
rcArea As RECT
End Type
Type CANDIDATEFORM
dwIndex As Long
dwStyle As Long
ptCurrentPos As POINTAPI
rcArea As RECT
End Type
Type CANDIDATELIST
dwSize As Long
dwStyle As Long
dwCount As Long
dwSelection As Long
dwPageStart As Long
dwPageSize As Long
dwOffset(1) As Long
End Type
Const STYLE_DESCRIPTION_SIZE = 32
Type STYLEBUF
dwStyle As Long
szDescription(0 To STYLE_DESCRIPTION_SIZE - 1) As Byte
End Type
' prototype of IMM API
Declare PtrSafe Function ImmInstallIME Lib "imm32.dll" Alias "ImmInstallIMEA" (ByVal lpszIMEFileName As String, ByVal lpszLayoutText As String) As LongPtr
Declare PtrSafe Function ImmGetDefaultIMEWnd Lib "imm32.dll" Alias "ImmGetDefaultIMEWnd" (ByVal hwnd As LongPtr) As LongPtr
Declare PtrSafe Function ImmGetDescription Lib "imm32.dll" Alias "ImmGetDescriptionA" (ByVal hkl As LongPtr, ByVal lpsz As String, ByVal uBufLen As Long) As Long
Declare PtrSafe Function ImmGetIMEFileName Lib "imm32.dll" Alias "ImmGetIMEFileNameA" (ByVal hkl As LongPtr, ByVal lpStr As String, ByVal uBufLen As Long) As Long
Declare PtrSafe Function ImmGetProperty Lib "imm32.dll" Alias "ImmGetProperty" (ByVal hkl As LongPtr, ByVal dw As Long) As Long
Declare PtrSafe Function ImmIsIME Lib "imm32.dll" Alias "ImmIsIME" (ByVal hkl As LongPtr) As Long
Declare PtrSafe Function ImmSimulateHotKey Lib "imm32.dll" Alias "ImmSimulateHotKey" (ByVal hwnd As LongPtr, ByVal dw As Long) As Long
Declare PtrSafe Function ImmCreateContext Lib "imm32.dll" Alias "ImmCreateContext" () As LongPtr
Declare PtrSafe Function ImmDestroyContext Lib "imm32.dll" Alias "ImmDestroyContext" (ByVal himc As LongPtr) As Long
Declare PtrSafe Function ImmGetContext Lib "imm32.dll" Alias "ImmGetContext" (ByVal hwnd As LongPtr) As LongPtr
Declare PtrSafe Function ImmReleaseContext Lib "imm32.dll" Alias "ImmReleaseContext" (ByVal hwnd As LongPtr, ByVal himc As LongPtr) As Long
Declare PtrSafe Function ImmAssociateContext Lib "imm32.dll" Alias "ImmAssociateContext" (ByVal hwnd As LongPtr, ByVal himc As LongPtr) As LongPtr
Declare PtrSafe Function ImmGetCompositionString Lib "imm32.dll" Alias "ImmGetCompositionStringA" (ByVal himc As LongPtr, ByVal dw As Long, lpv As Any, ByVal dw2 As Long) As Long
Declare PtrSafe Function ImmSetCompositionString Lib "imm32.dll" Alias "ImmSetCompositionStringA" (ByVal himc As LongPtr, ByVal dwIndex As Long, lpComp As Any, ByVal dw As Long, lpRead As Any, ByVal dw2 As Long) As Long
Declare PtrSafe Function ImmGetCandidateListCount Lib "imm32.dll" Alias "ImmGetCandidateListCountA" (ByVal himc As LongPtr, lpdwListCount As Long) As Long
Declare PtrSafe Function ImmGetCandidateList Lib "imm32.dll" Alias "ImmGetCandidateListA" (ByVal himc As LongPtr, ByVal deIndex As Long, lpCandidateList As CANDIDATELIST, ByVal dwBufLen As Long) As Long
Declare PtrSafe Function ImmGetGuideLine Lib "imm32.dll" Alias " ImmGetGuideLineA" (ByVal himc As LongPtr, ByVal dwIndex As Long, ByVal lpStr As String, ByVal dwBufLen As Long) As Long
Declare PtrSafe Function ImmGetConversionStatus Lib "imm32.dll" Alias "ImmGetConversionStatus" (ByVal himc As LongPtr, lpdw As Long, lpdw2 As Long) As Long
Declare PtrSafe Function ImmSetConversionStatus Lib "imm32.dll" Alias "ImmSetConversionStatus" (ByVal himc As LongPtr, ByVal dw1 As Long, ByVal dw2 As Long) As Long
Declare PtrSafe Function ImmGetOpenStatus Lib "imm32.dll" Alias "ImmGetOpenStatus" (ByVal himc As LongPtr) As Long
Declare PtrSafe Function ImmSetOpenStatus Lib "imm32.dll" Alias "ImmSetOpenStatus" (ByVal himc As LongPtr, ByVal b As Long) As Long
Declare PtrSafe Function ImmGetCompositionFont Lib "imm32.dll" Alias "ImmGetCompositionFontA" (ByVal himc As LongPtr, lpLogFont As LOGFONT) As Long
Declare PtrSafe Function ImmSetCompositionFont Lib "imm32.dll" Alias "ImmSetCompositionFontA" (ByVal himc As LongPtr, lpLogFont As LOGFONT) As Long
Declare PtrSafe Function ImmConfigureIME Lib "imm32.dll" Alias "ImmConfigureIME" (ByVal hkl As LongPtr, ByVal hwnd As LongPtr, ByVal dw As Long, lpData As Any) As Long
Declare PtrSafe Function ImmEscape Lib "imm32.dll" Alias "ImmEscapeA" (ByVal hkl As LongPtr, ByVal himc As LongPtr, ByVal un As Long, lpv As Any) As LongPtr
Declare PtrSafe Function ImmGetConversionList Lib "imm32.dll" Alias "ImmGetConversionListA" (ByVal hkl As LongPtr, ByVal himc As LongPtr, ByVal lpsz As String, lpCandidateList As CANDIDATELIST, ByVal dwBufLen As Long, ByVal uFlag As Long) As Long
Declare PtrSafe Function ImmNotifyIME Lib "imm32.dll" Alias "ImmNotifyIME" (ByVal himc As LongPtr, ByVal dwAction As Long, ByVal dwIndex As Long, ByVal dwValue As Long) As Long
Declare PtrSafe Function ImmGetStatusWindowPos Lib "imm32.dll" Alias "ImmGetStatusWindowPos" (ByVal himc As LongPtr, lpPoint As POINTAPI) As Long
Declare PtrSafe Function ImmSetStatusWindowPos Lib "imm32.dll" Alias "ImmSetStatusWindowPos" (ByVal himc As LongPtr, lpPoint As POINTAPI) As Long
Declare PtrSafe Function ImmGetCompositionWindow Lib "imm32.dll" Alias "ImmGetCompositionWindow" (ByVal himc As LongPtr, lpCompositionForm As COMPOSITIONFORM) As Long
Declare PtrSafe Function ImmSetCompositionWindow Lib "imm32.dll" Alias "ImmSetCompositionWindow" (ByVal himc As LongPtr, lpCompositionForm As COMPOSITIONFORM) As Long
Declare PtrSafe Function ImmGetCandidateWindow Lib "imm32.dll" Alias "ImmGetCandidateWindow" (ByVal himc As LongPtr, ByVal dw As Long, lpCandidateForm As CANDIDATEFORM) As Long
Declare PtrSafe Function ImmSetCandidateWindow Lib "imm32.dll" Alias "ImmSetCandidateWindow" (ByVal himc As LongPtr, lpCandidateForm As CANDIDATEFORM) As Long
Declare PtrSafe Function ImmIsUIMessage Lib "imm32.dll" Alias "ImmIsUIMessageA" (ByVal hwnd As LongPtr, ByVal un As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long
Declare PtrSafe Function ImmGetVirtualKey Lib "imm32.dll" Alias "ImmGetVirtualKey" (ByVal hwnd As LongPtr) As Long
Declare PtrSafe Function ImmRegisterWord Lib "imm32.dll" Alias "ImmRegisterWordA" (ByVal hkl As LongPtr, ByVal lpszReading As String, ByVal dw As Long, ByVal lpszRegister As String) As Long
Declare PtrSafe Function ImmUnregisterWord Lib "imm32.dll" Alias "ImmUnregisterWordA" (ByVal hkl As LongPtr, ByVal lpszReading As String, ByVal dw As Long, ByVal lpszUnregister As String) As Long
Declare PtrSafe Function ImmGetRegisterWordStyle Lib "imm32.dll" Alias " ImmGetRegisterWordStyleA" (ByVal hkl As LongPtr, ByVal nItem As Long, lpStyleBuf As STYLEBUF) As Long
Declare PtrSafe Function ImmEnumRegisterWord Lib "imm32.dll" Alias "ImmEnumRegisterWordA" (ByVal hkl As LongPtr, ByVal RegisterWordEnumProc As LongPtr, ByVal lpszReading As String, ByVal dw As Long, ByVal lpszRegister As String, lpv As Any) As Long
' the IME related messages
Const WM_CONVERTREQUESTEX = &H108
Const WM_IME_STARTCOMPOSITION = &H10D
Const WM_IME_ENDCOMPOSITION = &H10E
Const WM_IME_COMPOSITION = &H10F
Const WM_IME_KEYLAST = &H10F
Const WM_IME_SETCONTEXT = &H281
Const WM_IME_NOTIFY = &H282
Const WM_IME_CONTROL = &H283
Const WM_IME_COMPOSITIONFULL = &H284
Const WM_IME_SELECT = &H285
Const WM_IME_CHAR = &H286
Const WM_IME_KEYDOWN = &H290
Const WM_IME_KEYUP = &H291
' wParam for WM_IME_CONTROL
Const IMC_GETCANDIDATEPOS = &H7
Const IMC_SETCANDIDATEPOS = &H8
Const IMC_GETCOMPOSITIONFONT = &H9
Const IMC_SETCOMPOSITIONFONT = &HA
Const IMC_GETCOMPOSITIONWINDOW = &HB
Const IMC_SETCOMPOSITIONWINDOW = &HC
Const IMC_GETSTATUSWINDOWPOS = &HF
Const IMC_SETSTATUSWINDOWPOS = &H10
Const IMC_CLOSESTATUSWINDOW = &H21
Const IMC_OPENSTATUSWINDOW = &H22
' wParam for WM_IME_CONTROL to the soft keyboard
' dwAction for ImmNotifyIME
Const NI_OPENCANDIDATE = &H10
Const NI_CLOSECANDIDATE = &H11
Const NI_SELECTCANDIDATESTR = &H12
Const NI_CHANGECANDIDATELIST = &H13
Const NI_FINALIZECONVERSIONRESULT = &H14
Const NI_COMPOSITIONSTR = &H15
我20多年的VBA实践经验,全部浓缩在下面的各个教程中: