So, I have a custom button (button A) which has been Subclassed (button B), and an instance of button B (button C), which has been dragged onto a window. I’m trying to get the MouseDown event of button C to fire using RaiseEvent. Here’s what I did:
- Inserted an Event Definition for “MouseDown” into button B.
- Inserted a MouseDown event into button B with the code: “RaiseEvent MouseDown.”
- Inserted a MouseDown event into button C with the code: “MessageBox(“Button Clicked”).”
I’ve tried several variations of that as well but the event doesn’t fire. Can someone tell me what I’m doing wrong?
Thanks!
Never mind. I realized what I was doing wrong. To implement a MouseDown event for Button C, the correct procedure is as follows:
-
Insert a MouseDown Event Definition and MouseDown Event Handler into Button A.
-
Insert another Event Definition into button A and give it a name of your choice (e.g., “Action”).
-
In the MouseDown Event for button A, add the code:
RaiseEvent Action
Return True
-
Insert the “Action” event into button C.
-
Implement your code in the “Action” event.
Do you ever need to do any processing in the MouseDown handler in A or B? If not, you can skip right to C and omit the handlers in A and B.
I was really just using MouseDown to illustrate the process. At this point, I’ve never needed to process anything in the MouseDown event for A or B. However, I always use the Open event for A or B to create the Constructor. Then, I’ll often need to override the event for C. Hence, the reason I was trying to figure out how to use RaiseEvent.
1 Like
Your Button are a new class ?
I suppose True.
In your new class:
1 - you create a new method (“met”) and you write
“RaiseEvent ( ev )”
2- you create a new event Definition whith this name “ev”
3- you put an instance in your window
4- you execute you method “met”