Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are there additional events in VBA?

Status
Not open for further replies.

mnik3

Technical User
May 11, 2009
10
US
So, as far as I can tell, the "events" in VBA Userforms (such as UserForm1_Click, ect..) are either very similar or identical to SendMessage + BN_CLICKED. So, that leads to my question, are there additional events that you can filter for? Not the _Terminate and _Activate type of events in the drop-down menu, but other not-as-obvious events. Yesterday I wanted to filter certain messages to my window (example: WM_WINDOWPOSCHANGED), so I subclassed and manually filtered, using a WindowProc sub and the CallWindowProc function (I was having issues with the repainting of the window, but that is beside the point). if anyone knows an answer to this question that'd be great! Thanks in advance.
 
The form events are really wrappers for the API functions that provide you and interface with them that's more friendly for example, .AddItem event of the listbox is a wrapper for LB_ADDSTRING.

If you subclass the window the way you say, you can intercept any message that is broadcast you want, from power-down's to custom messages between you apps. Basically, if window's send it's (providing it's to a top level window broadcast) you can inetcept it.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

http
 
So are there "friendly" forms for capturing other messages, so that I don't have to worry about correctly hooking/unhooking?
 
It all depends what messages you want to trap/handle. From what you're saying I imagine you want events that aren't exposed from the form's/control's events natively. If that is the case then no to friendly versions, it's down to you to sub class I'm afraid.

What notifications are you wanting to handle?

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

http
 
WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING. This little project is mainly just to increase my experience with subclassing. I hadn't really planned on changing what I've got, I read something this morning and then it occurred to me that maybe VBA had a built-in message capturing mechanism that allowed a user to use them as events.
 
maybe VBA had a built-in message capturing mechanism that allowed a user to use them as events
Unfortunately not, the only built in capturing mechanism are the events you can access at the moment.

Anything further you'll need to handle yourself I'm afraid.

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

http
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top