|
-
Dec 5th, 2000, 08:29 AM
#1
Thread Starter
Lively Member
How can I add an onclick event to a control that does not have it?
Kiziltan Yuceil
Freelance Web/VB/VBA Programmer
"It's not what you know it's to whom you consult and with whom you collaborate"
-
Dec 8th, 2000, 08:25 PM
#2
Hyperactive Member
I think I have posted to this before, but I am not sure.
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.
Code:
Private Sub UserControl_Click()
RaiseEvent Click()
End sub
Hope it works
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Dec 11th, 2000, 04:09 AM
#3
Thread Starter
Lively Member
Yes but..
I dont have the source code for the control..
Kiziltan Yuceil
Freelance Web/VB/VBA Programmer
"It's not what you know it's to whom you consult and with whom you collaborate"
-
Dec 13th, 2000, 04:32 PM
#4
Hyperactive Member
make another control
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...
-scott
he he he
-
Dec 17th, 2000, 01:24 AM
#5
Hyperactive Member
Use Scott's Idea
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.
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.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|