Thanks Frank and Sergio,
My real question was why won't AddressOf operator work in VBA. In subsequent
research I find that it will only run in modules - ie bas files. In VBA
there are no individual files just the project file. So my solution was to
create a class (probably very similar to yours Sergio) that has one method
which calls the same code that I posted only in a bas file. Seems kinda
wonky to me that VBA will only allow this in a file with a bas extension.
Then again, I could be wrong.
Either way thank you for your contributions.
M
"Sergio DeAlbuquerque"
wrote in message
news:63C0F496934A0308478A1B3DCCAD7144@in.WebX.SaUCah8kaAW...
> Hi Mike,
> Attached you will find a BETA version of DLL I've been working on. It
gives
> you Windows message hooking ability, window subclassing, and will window
> enumarating and window finding functions. The methods should be pretty
self
> explanitory. I can send you the source code if you would like to see how
it
> works behind the scenes.
> To use it, you need to add a reference to you project to the DLL.
> You then need to instanciate the object.
> Use do the following:
> 'Declaration section
> Private WithEvents objWindHookAs clsWindHook
>
> Then you need to create the object. Place this code before you need to use
> the object (in form activate for example)
>
> Set objWindHook = New clsWindHook
>
> Now the object is created and you can use its methods.
> Subclassing and windhook will generate events to give you the windows
> message.
> Use the EnumWind method to Enumerate windows. It will return an array of
> variants. The array works in increments of Three, The first value is the
> window handle, second is the window text, the third is the class name. The
> array continues in this fashion. The array should contain (n*3) elements
> where n is the number of windows.
>
> Example:
> Dim WindInfo() As Variant
> objWindHook.EnumWind WindInfo()
> Debug.Print "hwnd:", WindInfo(0), "Text", WindInfo(1), "Class",
WindInfo(2)
>
> Safe your work often. Incorrect input can sometimes bring AutoCAD crashing
> down. Especially when subclassing.
>
> Hope you like it,
>
> --
> Sergio DeAlbuquerque
> President
>
> Matrix Technical Services Inc.
> 172 N.Bicycle Path
> Selden, NY 11784
>
> Ph: 631-736-9001
> Fax: 631-696-8538
>
> http://www.matrixengg.com
> sdealbuquerq@matrixengg.com
> "CAD services, machine design, VB and VBA application development"
>
>
----------------------------------------------------------------------------
----
> MZÿÿ¸@к´ Í!¸LÍ!This program cannot be run in DOS mode.
> $cÜÛ'o²^'o²^'o²^¤s¼^&o²^Np»^%o²^N¿^&o²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'·åK.(ôâßØÑ»¬Ô'·åK.(ô
0'ÿÿÿÿÿÿÿÿ´''`'ü'ü'Hook Rev2: Hook and subclassing Ã`¤Â`|?bhwndÌ$'´
'l '$ 'Ø'"'@'ô''¬''d'''''Ä'|'0'VB5!!*~
>
ô'ð0ÿÿÿéÄ'Ä'Ô'xfOWindHookR2WindHookWindHook0'È''ÿÿÿÿ"'`'$'c°'P
'°'¸'´'¼' ä'd'@Â``'p''@H'ÿÿÿÿ''Ø'b
'ÿÿÿÿD'Q'^'k'x'.'''Y'¬'¹'Æ'Ó'à'í'¼'8''"'s'Ø'å'l$ÿÿé
÷'l$ÿÿéZ'l$ÿÿé½'l$ÿÿé
l$ÿÿéól$ÿÿé?l$ÿÿé)l$ÿÿéìl$ÿÿé_l$ÿÿéÒl$ÿÿéEl$ÿÿé8'l$
GéÛl$Gén ô0'0)'ÀO'``'&''`'*\AC:\My Documents\Visual Studio
Projects\Hooking and
SubClassing\WindHook.vbp0'``'X('ÿÿÿÿP`'ÞßØÑ»¬Ô'·åK.(ô"'4'
8'ÿÿÿÿÔ''''ä'ÿÿ^'Ä'ÿÿÿÿè '$`'('ÿÿA
'''''(''8''D''P''\''p''''''INDHO~1.DLLojclsWindHookWindProcWindHook+=ûüú
h§8+3qµáßØÑ»¬Ô'·åK.(ô*=ûüú h§8+3qµàßØÑ»¬Ô'·åK.(ôâßØÑ»¬Ô'·åK.(ô!=ûüú
h§8+3qµClass!JTê-ÈÑ'£ä É
> ê,c:\WINDOWS\SYSTEM\msvbvm60.dll\3VBRUN¨'
¸'Ü'Xc'^Æ`isSubClassedSetWindHookReleaseWindHookSubClassUnSubClassEnumWind
EnumChildWindFindParentWindFindChildWindFindAllWindHookMsgReceivedSubClassMs
gReceivedSubClassAfterMsg T00,$(
user32'SetWindowsHookExA'''\c'¡dc'
Àtÿàh0'¸°''ÿÐÿàUnhookWindowsHookEx'h'hc'¡pc'
Àtÿàh|'¸°''ÿÐÿàCallNextHookEx'´'tc'¡|c' ÀtÿàhÄ'¸°''ÿÐÿà
kernel32RtlMoveMemoryü' ''c'¡^c'
Àtÿàh'''¸°''ÿÐÿàSetWindowLongA'T''Oc'¡"c'
Àtÿàhd''¸°''ÿÐÿàCallWindowProcA'o''~c'¡ c'
Àtÿàh¬''¸°''ÿÐÿàGetWindowLongA'ä''¤c'¡¬c'
Àtÿàhô''¸°''ÿÐÿàGetCurrentThreadIdü','°c'¡¸c' Àtÿàh@'¸°''ÿÐÿà
IsWindow'x'¼c'¡Äc' Àtÿàh"'¸°''ÿÐÿà
EnumWindows¸fĤYI»xª8<»'¼'Èc'¡Ðc'
ÀtÿàhØ'¸°''ÿÐÿà'EnumChildWindows' 'Ôc'¡Üc' Àtÿàh$
'¸°''ÿÐÿàGetClassNameA'\ 'àc'¡èc' Àtÿàhl '¸°''ÿÐÿàGetWindowTextA'¤
'ìc'¡ôc' Àtÿàh´ '¸°''ÿÐÿà,,è!a ¤,Subclassed
^WindHookLCurrent Hook Object Already SubClassed2Not Valid Window Handle:
> (No Window Subclassedunsubclassed *Invalid Window
Handle*VBA6.DLL__vbaRaiseEvent__vbaFailedFriend__vbaStrCopy__vbaFreeStr__vb
aStrCmp__vbaAryCopy__vbaRedim__vbaAptOffset__vbaFreeStrList__vbaStrI4__vbaSt
rMove__vbaStrCat__vbaFreeVarList__vbaHresultCheckObj__vbaVarDup__vbaObjSet__
vbaFreeObj__vbaObjSetAddref__vbaSetSystemError#=ûüú h§8+3qµ"=ûüú
h§8+3qµ´#'Ä#'yO3TfÏ'·
ª`Ó"Hooking__vbaStrTextLike__vbaStrTextCmp__vbaFreeVar__vbaStrToUnicode__vb
aLsetFixstr__vbaStrToAnsi__vbaVarMove__vbaFixstrConstruct__vbaRedimPreserve_
_vbaFreeObjList__vbaNew2´#'øc'__vbaErrorOverflow__vbaGenerateBoundsError__vb
aCastObj¼('Ä('Ì('Ä('È''ÿÿÿÿÌ('Ô('à('ô('Ô('à('@''''ð&'Ì('ì('Ô('à('ü(')' )'
)'ü(')' )')'')'ü(')' )')'')')ÿÿ`%''1ÿÿ`'%''o!ÿÿ`%''-ÿÿ`%''
9ÿÿ`0%''(00 Aÿÿ
`<%''(00ÿÿh%''#%ÿÿ`%''=ÿÿ``%''(00ÿÿÿÿp%'ÿÿÿÿ"%'((((#ÿÿ
ÿÿ%'#5ÿÿ`
%''o&'ð%'¤&'¨%'&'Ì%'h''8&'È&'\&'8'ÿÿÿÿ''T%'H%'%'TXh
'h`d'hdd'Pé,ëÿÿXh 'h`d'hdd'PérëÿÿXh 'h`d'hdd'PébëÿÿXh
'Pé\ëÿÿ0'ÿÿÿÿ(%'('ÿÿÿÿ(:-P Matrix WindHook Rev2: Hook and
subclassingä''üc'hwndWindArrphWndClassNameWindTitlechWndahWndlhWndlMsgwPa
ramlParameatMessageÌÌÌÌÌÌÌÌééééÌÌÌÌÌÌÌÌÌÌÌÌU<ìfì h&''d¡Pd?%fì
SVW?eôÇEø''3ÿ?}ü >
?M´».|ÿÿÿM¼?Eo?E¬ÇE"T!'?|ÿÿÿÿè'UOMÌÇE"
ProductVersion2.008InternalNameWindHookR2H'OriginalFilenameWindHookR2.dl
l,OLESelfRegisterâßØÑ»¬Ô'·åK.(ôàßØÑ»¬Ô'·åK.(ôMSFT A'ÿÿÿÿ
dÈP,ÿÿÿÿÄ ÿÿÿÿÐ'ÿÿÿÿ¤
ÿÿÿÿ|ÿÿÿÿü¨ÿÿÿÿìÿÿÿÿì¤ÿÿÿÿ4ÿÿÿÿÄ(ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ4!ø
> xÐ'ÿÿÿÿÿÿÿÿDÿÿÿÿ%! ÿÿÿÿ0,ÿÿÿÿÿÿÿÿÿÿÿÿ$!
@^Dÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿ`xÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ{?Pi»Ð'¨ÿ
É'YÿÿÿÿÿÿÿÿßßØÑ»¬Ô'·åK.(ôþÿÿÿÿÿÿÿáßØÑ»¬Ô'·åK.(ôdÿÿÿÿ0ÀFÿÿÿÿÀF0àßØÑ»¬
Ô'·åK.(ôÿÿÿÿâßØÑ»¬Ô'·åK.(ôÈÿÿÿÿÿÿÿÿÈÿÿÿÿÿÿÿÿ`H-StdOle2.TlbWWWÿÿÿÿè
ÿÿÿÿ<ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÔÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿ,ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ@ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿ¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿPÀü¬xÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿhOÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿDÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿ¼ÿÿÿÿÿÿÿÿÐÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(ÿÿÿÿÿÿÿÿ,ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtÿÿÿÿÿÿÿÿÿÿÿÿ
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,óWindHo
okÿÿÿÿ 86Z_clsWindHookdÿÿÿÿ 8æ-clsWindHookWÈÿÿÿÿ8Fc__clsWindHookWWWÿÿÿÿ
00isSubClassedÿÿÿÿ 2ºSetWindHookWÿÿÿÿñûReleaseWindHookWÿÿÿÿ1
SubClassÿÿÿÿÿÿÿÿ/Áhwndÿÿÿÿ
> ]SUnSubClassWWÿÿÿÿfEnumWindÿÿÿÿ`0WindArrWÿÿÿÿ$?EnumChildWindWWWÿÿÿÿÿÿÿ
ÿT|phWndWWWÿÿÿÿ!"FindParentWindWWÿÿÿÿÿÿÿÿ ¹©ClassNameWWWÿÿÿÿÿÿÿÿ
ìWindTitleWWWÿÿÿÿº±FindChildWindWWWÿÿÿÿÿÿÿÿ©chWndWWWÿÿÿÿ
ÚàFindAllWindWÿÿÿÿÿÿÿÿðahWndWWWÈÿÿÿÿ§üHookMsgReceivedWÿÿÿÿÿÿÿÿã4lhWndWWWÿ
ÿÿÿÿÿÿÿ¨lMsgÿÿÿÿÿÿÿÿbwParamWWÿÿÿÿÿÿÿÿ.7lParamWWÿÿÿÿÿÿÿÿ
> ®-eatMessageWWÈ\9ïSubClassMsgReceivedWÈÿÿÿÿû«SubClassAfterMsg/(:-P
Matrix WindHook Rev2: Hook and subclassingWWW @
`@@/!Oÿÿÿÿ¤$L'Dÿÿÿÿ
> !4 %4 $)D À-4 $1T ü05d
,ü<9| , \ tH=O ,¨ \ t< A|
Ô \ th```````` ``x¬Ðè@O¼$
(<PT¬ (<PHt
(<èh^T¨
'1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