暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

六十四位Office中API函数声明语句第61讲

VBA语言専攻 2021-09-23
118
【分享成果,随喜正能量】贫莫大于不闻道,贱莫大于不知耻,一个人真正的贫穷,是不明事理,一个人真正的卑贱,是不知羞耻。知耻才能远辱,没有知耻心的人,做了错事不觉得惭愧,对不起别人也不觉得内疚,这样的人,很难在社会上立足。知耻是一种自我约束的能力,做人要有底线,做事要讲规矩。生活各自不易,个人所求不同,各自立场不一,勿在别人心中修行自己,勿在自己心中强求别人。


跟我学VBA,我这里专注VBA, 授人以渔。我98年开始,从源码接触VBA已经20余年了,随着年龄的增长,越来越觉得有必要把这项技能传递给需要这项技术的职场人员。希望和数据打交道的朋友,都来学习VBA,利用VBA,起码可以提高自己的工作效率,可以有时间多陪陪父母,多陪陪家人,何乐而不为呢?
这讲我们继续学习64位Office API声明语句学习之61讲,这些内容是MS的权威资料,看似枯燥,但对于想学习API函数的朋友是非常有用的。


' Color Types
Const CTLCOLOR_MSGBOX = 0
Const CTLCOLOR_EDIT = 1
Const CTLCOLOR_LISTBOX = 2
Const CTLCOLOR_BTN = 3
Const CTLCOLOR_DLG = 4
Const CTLCOLOR_SCROLLBAR = 5
Const CTLCOLOR_STATIC = 6
Const CTLCOLOR_MAX = 8   '  three bits max

Const COLOR_SCROLLBAR = 0
Const COLOR_BACKGROUND = 1
Const COLOR_ACTIVECAPTION = 2
Const COLOR_INACTIVECAPTION = 3
Const COLOR_MENU = 4
Const COLOR_WINDOW = 5
Const COLOR_WINDOWFRAME = 6
Const COLOR_MENUTEXT = 7
Const COLOR_WINDOWTEXT = 8
Const COLOR_CAPTIONTEXT = 9
Const COLOR_ACTIVEBORDER = 10
Const COLOR_INACTIVEBORDER = 11
Const COLOR_APPWORKSPACE = 12
Const COLOR_HIGHLIGHT = 13
Const COLOR_HIGHLIGHTTEXT = 14
Const COLOR_BTNFACE = 15
Const COLOR_BTNSHADOW = 16
Const COLOR_GRAYTEXT = 17
Const COLOR_BTNTEXT = 18
Const COLOR_INACTIVECAPTIONTEXT = 19
Const COLOR_BTNHIGHLIGHT = 20

Declare PtrSafe Function GetSysColor Lib "user32" Alias "GetSysColor" (ByVal nIndex As Long) As Long
Declare PtrSafe Function SetSysColors Lib "user32" Alias "SetSysColors" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long

Declare PtrSafe Function DrawFocusRect Lib "user32" Alias "DrawFocusRect" (ByVal hdc As LongPtr, lpRect As RECT) As Long
Declare PtrSafe Function FillRect Lib "user32" Alias "FillRect" (ByVal hdc As LongPtr, lpRect As RECT, ByVal hBrush As LongPtr) As Long
Declare PtrSafe Function FrameRect Lib "user32" Alias "FrameRect" (ByVal hdc As LongPtr, lpRect As RECT, ByVal hBrush As LongPtr) As Long
Declare PtrSafe Function InvertRect Lib "user32" Alias "InvertRect" (ByVal hdc As LongPtr, lpRect As RECT) As Long
Declare PtrSafe Function SetRect Lib "user32" Alias "SetRect" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare PtrSafe Function SetRectEmpty Lib "user32" Alias "SetRectEmpty" (lpRect As RECT) As Long
Declare PtrSafe Function CopyRect Lib "user32" Alias "CopyRect" (lpDestRect As RECT, lpSourceRect As RECT) As Long
Declare PtrSafe Function InflateRect Lib "user32" Alias "InflateRect" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Declare PtrSafe Function IntersectRect Lib "user32" Alias "IntersectRect" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
Declare PtrSafe Function UnionRect Lib "user32" Alias "UnionRect" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
Declare PtrSafe Function SubtractRect Lib "user32" Alias "SubtractRect" (lprcDst As RECT, lprcSrc1 As RECT, lprcSrc2 As RECT) As Long
Declare PtrSafe Function OffsetRect Lib "user32" Alias "OffsetRect" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Declare PtrSafe Function IsRectEmpty Lib "user32" Alias "IsRectEmpty" (lpRect As RECT) As Long
Declare PtrSafe Function EqualRect Lib "user32" Alias "EqualRect" (lpRect1 As RECT, lpRect2 As RECT) As Long
Declare PtrSafe Function PtInRect Lib "user32" Alias "PtInRect" (lpRect As RECT, pt As POINTAPI) As Long

Declare PtrSafe Function GetWindowWord Lib "user32" Alias "GetWindowWord" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As Integer
Declare PtrSafe Function SetWindowWord Lib "user32" Alias "SetWindowWord" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
Declare PtrSafe Function GetClassWord Lib "user32" Alias "GetClassWord" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As Long
Declare PtrSafe Function SetClassWord Lib "user32" Alias "SetClassWord" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
Declare PtrSafe Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As LongPtr

#If Win64 Then
Declare PtrSafe Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongPtrA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
Declare PtrSafe Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongPtrA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
Declare PtrSafe Function GetClassLongPtr Lib "user32" Alias "GetClassLongPtrA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
Declare PtrSafe Function SetClassLongPtr Lib "user32" Alias "SetClassLongPtrA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#Else
Declare PtrSafe Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
Declare PtrSafe Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
Declare PtrSafe Function GetClassLongPtr Lib "user32" Alias "GetClassLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
Declare PtrSafe Function SetClassLongPtr Lib "user32" Alias "SetClassLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr

' Provided for reference only.  Please use the LongPtr versions instead.
Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As Long
Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare PtrSafe Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As Long
Declare PtrSafe Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
#End If
第1套教程:VBA代码解决方案
第2套教程:VBA数据库解决方案
第3套教程:VBA数组与字典解决方案
第4套教程:VBA代码解决方案之视频(第一套的视频讲解)
第5套教程:VBA中类的解读和利用
第6套教程:VBA信息获取与处理
第7套教程:VBA之EXCEL应用
第8套教程:VBA之Word应用(最新推出)
上述教程的学习顺序:
① 7→1→3→2→6→5或者7→4→3→2→6→5。
② 7→8


文章转载自VBA语言専攻,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论