PDA

Click to See Complete Forum and Search --> : Adding new events 2 a control!!! ASAP!!!!!


Reddawn
Dec 5th, 2000, 07:29 AM
How can I add an onclick event to a control that does not have it?

Wak
Dec 8th, 2000, 07:25 PM
Open the ocx or dll, and after finding the right control add under the option explicit statement:

Event Click()

then when you want the event to occur, RaiseEvent. eg.


Private Sub UserControl_Click()
RaiseEvent Click()
End sub


Hope it works :)

Reddawn
Dec 11th, 2000, 03:09 AM
I dont have the source code for the control..

Scott Penner
Dec 13th, 2000, 03:32 PM
The easiest thing I can think of would be to build another control. You can simply drop in the control you are trying to change, use the ActiveX interface wizard to pass through all the properties, methods and events from the existing control, then add your own click event. You can use the code above to do that...

Wak
Dec 17th, 2000, 12:24 AM
Since you didn't reply, I am guessing that you are still having trouble with it.

Follow these steps:

1.)Open VB
2.)On the Wizard select Active X Control
3.)Once loaded press Ctrl + T
4.)Select the control you wish to alter
5.)Once the control is loaded drag it from the controls menu to the user control

6.)Go to code section
7.) Add folowing code.


Option explicit
Event Click()
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Private Sub Usercontrol_Initialize()
Usercontrol.Width = ModifyingControl.Width
Usercontrol.Height = ModifyingControl.Height
End Sub

Private Sub Usercontrol_Click()
RaiseEvent Click()
End Sub

Private Sub Usercontrol_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub

Private sub Usercontrol_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub

Private Sub ModifyingControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub

Private sub ModifyingControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub



As simple as that. You might not need all the code included, depending on the control.

If it doesn't work, just reply saying what it has a problem with.