|

楼主 |
发表于 2017-7-30 01:11:18
|
显示全部楼层
来自: 中国陕西西安
- Option Explicit$ F( E: @" f# `6 Z- P6 }
* U1 O: I& Q# x' x2 R- ' 定义用户类型,以减少#if VBA7语句的数量,但不能消除他们...
' d& G- U9 T0 {3 H+ d1 M# X( R - Private Type LongPtr_T! z/ G" A% ?4 U. I0 n$ V7 u' E
- #If VBA7 Then- H5 V% c7 F) U" c( {5 a1 j# b4 V
- Value As LongPtr
9 b5 J% Z' S: D1 \$ i - ' Compare automatically resized LongPtr to fixed size Long and LongLong4 T7 h1 z# \) Z; u
- #Else
I. H Q- V4 X# C+ x { x - Value As Long4 k0 A' T4 _- [0 \: V
- #End If
- ~1 q6 N! M+ ?, z6 S3 V. Y4 e - End Type* J2 V6 p. A6 G; E
- 1 v& @( k. V6 V) D% o h
- ' Win32 数据类型. Different signatures for different versions of VBA
! B" u. I4 {" \" O - Private Type BROWSEINFO, P7 T! f9 ?- n" `& Z6 j* i
- #If VBA7 Then
4 B+ g$ g [# j2 s+ h+ [ - hWndOwner As LongPtr, I3 s/ i) U7 k: |' a
- pIDLRoot As LongPtr8 ~( g# z% A3 k9 u1 a# a0 ~$ R3 f
- pszDisplayName As Long @" ^: V1 J+ t& |
- lpszTitle As String
& b, }( f5 O1 `2 v - ulFlags As Long
* y) n' Z/ H4 d, |* _ - lpfnCallback As LongPtr) M9 N$ m4 A8 c5 W* R% N
- lParam As Long
; a7 G+ W4 M+ { Q - iImage As Long
' J8 \3 x7 L3 i; q - #Else
# d. H/ g; Q7 e - hWndOwner As Long
& P) O% {7 {) \" [& P( {" H; \ - pIDLRoot As Long3 R S I2 J5 D/ f1 \! Z- N0 ^
- pszDisplayName As Long5 D! `. Q# _$ i( V6 M5 @+ X }6 M- V
- lpszTitle As String
; Z3 y' ?8 f8 ?9 y4 k+ p c - ulFlags As Long
, F5 R9 x/ Z& N9 z! W - lpfnCallback As Long) f/ X1 | V1 I+ N
- lParam As Long
8 f, q2 `9 a( n# E6 o+ T - iImage As Long& h+ l9 U) D) v. O/ q
- #End If$ _% {6 }' a; Y/ n
- End Type. ~' c% x5 s& S. ^, j
- 8 @1 D1 ` ?5 |$ F6 I+ ^
- Private Const MAX_PATH = 260! w$ l; ~: F8 G# L
- 'Directories only
! c; R+ s+ g8 M: g- {1 n9 E; H - Private Const BIF_RETURNONLYFSDIRS = &H1&( _! Z+ W2 h8 U' f/ q
- 'Windows 2000 (Shell32.dll 5.0) extended dialog, b; j! I& z; k6 o4 ]
- Private Const BIF_NEWDIALOGSTYLE = &H40
1 T$ e) i; C7 c0 ? R7 t - ' show edit box7 i7 |2 o# r. C6 q; o$ k! W/ u& b
- Private Const BIF_EDITBOX = &H10&
4 q" V6 V) T6 D/ l2 m1 ` - 0 K% c0 Q: X6 S) H+ A5 y% q$ n6 g
- Private Const WM_USER = &H400
! J0 W: h6 A6 j7 N, K) m! R - Private Const BFFM_INITIALIZED = 1
; M0 k4 x6 x. \& c* m3 y6 F - Private Const BFFM_SELCHANGED = 2
( [, B: D" j1 u' b - Private Const BFFM_SETSTATUSTEXTA = (WM_USER + 100)" B1 E r* h4 n, w7 C! f9 N9 o
- : X; [ V* I, E# s" q# G
- Private Const BFFM_SETSELECTIONA = (WM_USER + 102)
2 W8 K0 c b5 i" o: G } - Private Const BFFM_SETEXPANDED = (WM_USER + 16)
3 f: v. R1 v; N0 q/ z - 3 I# j' `$ A- ~2 g3 l3 V2 A/ w
- Private m_sDefaultFolder As String/ t% E. m& d% h, H5 O9 Q9 m% k+ j& P
/ D0 n$ w6 m4 G3 P/ H# Q! u- Public Const SWP_NOMOVE = 2
% B* M4 v2 R$ m - Public Const SWP_NOSIZE = 1
' C$ s4 s, `2 ?* N% R( Y - Private Const SWP_NOZORDER = 4
( e- d$ v# f0 X1 f \7 h. n
4 M& Q6 u$ {4 X/ J- Private Type RECT1 P9 D% w* C. q- X# H b1 C
- Left As Long4 X: s. J. m% ~5 ?8 Z0 Q9 Y
- Top As Long
* \! b( y% B, o* T - Right As Long/ i& o) n) ^% |* }
- Bottom As Long
& U2 Z- H: Q$ [4 h( h - End Type
) ^! ]' S/ r7 D; s: `8 |. w* ~ - " M3 n! J: R' `/ H. h7 i9 V+ U) f* v
- ' Win32 API declarations. Different signatures for different versions of VBA.: b' @3 d7 U$ f! J
- ' Note the mandatory use of PtrSafe keyword in VBA7.% h) b0 M7 v. k+ ~( }
- #If VBA7 Then
, u& r1 t* ~" v. ^4 b" I. [ - Private Declare PtrSafe Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
8 N) V n" {- c! P4 s2 c6 u - Private Declare PtrSafe Function SHBrowseForFolder Lib "Shell32" (lpbi As BROWSEINFO) As Long- Q! y9 Q2 Q/ }0 j
- Private Declare PtrSafe Function SHGetPathFromIDList Lib "Shell32" (ByVal pidList As LongPtr, ByVal lpBuffer As String) As Long& K3 g- j2 z2 J! q S" n6 ]" M
- Private Declare PtrSafe Sub CoTaskMemFree Lib "ole32" (ByVal hMem As LongPtr)
: R9 h( z3 \3 h9 d0 C4 }$ | - Private Declare PtrSafe Function SetWindowPos Lib "USER32" (ByVal hWnd As LongPtr, _/ V9 q4 B; f g1 f+ R y% R8 m
- ByVal hWndInsertAfter As LongPtr, _
* w) U- U! E4 Y8 d9 Z# M - ByVal x As Long, _) G+ c' ` L) s
- ByVal y As Long, _
* l: U$ l$ H6 m: T& [: F - ByVal cx As Long, _
( e$ p& z$ T; s - ByVal cy As Long, _
! C! q" W% A9 a) Z$ V - ByVal wFlags As Long) As Long+ r0 v/ Q4 z, K' a% Q/ ~8 W
- Private Declare PtrSafe Function GetWindowRect Lib "user32.dll" (ByVal hWnd As LongPtr, lpRect As RECT) As Long& ?9 v1 K2 a! h! Z) p; G3 S
- 9 R$ i( u3 n# o- C* s5 A9 S
- #Else# a0 u! K. X( X
- Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long! S# W) f0 K% w/ N9 E
- Private Declare Function SHBrowseForFolder Lib "Shell32" (lpbi As BROWSEINFO) As Long I& P# u( |/ d5 N) N
- Private Declare Function SHGetPathFromIDList Lib "Shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long% R+ s! ?0 R5 S- _9 T! t5 f: R! y
- Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal hMem As Long)# N9 g- | i; Z5 H4 O
- Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
! X0 r- t8 ~: [% S: ^ - ByVal hWndInsertAfter As Long, _
* t" z8 t/ P; X# C$ G$ _* t2 v - ByVal x As Long, _* `% R/ k" ]- w: U
- ByVal y As Long, _
1 E6 X1 M! Z) }3 R4 }2 b, E - ByVal cx As Long, _
0 ]5 x" N3 [) i$ I: J* U& K - ByVal cy As Long, _4 g1 |# p, Y7 R4 @9 A) T
- ByVal wFlags As Long) As Long$ s s2 m1 {2 }- `
- Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hWnd As Long, lpRect As RECT) As Long
+ j7 `2 Z+ N3 _* t" X+ w
$ @& O* T( o: l% }' v- #End If, B/ X" g/ T: f } l. H) [
- & }# O2 n( L) z" M' [" d n" I
- Private lastKnownPosition As RECT
( u9 {7 J2 _6 Z" Q" l: o6 N# G- G - Private lockLastKnownPosition As Boolean
复制代码
4 ~. g# j& `( p8 e梁大,将这一段修改一下 |
|