3
votes

We have an old OCX, that used in old VB application. Both of them do not support by developer now. and source code also not available. OCX contains a function which calculate a value and now we have to change the formula of calculation. Is there any way to override method and create a news ocx with same functionality?

Edit: ocx contain a date picker which using mscomctl2.ocx, our formula is based on selected date, so if we can find a solution to change date after selection, we can reach to our need.

2
That hooking link will be of no use. You cannot modify the compiled OCX. You can replace it with a new OCX (compiling with binary compatibility against the old one) but you would need to duplicate all the functionality in its public interfaces.Alex K.
@AlexK. Couldnt you just write another control that is a wrapper for the one the user is describing and do the correct calculation in the one function Ashian is interested in? I guess this depends on what kind of control it is as well and that it exposes the properties he needs to do the calculation he needs to do.Max Young
The new OCX would need the same typelib clsids/progids as the old one for the VB6 app to be able to load & early bind to it - you can do that if you compiled the new with binary compatibility with the old - but then you would need to find a hack to access the old OCX which from the perspective of COM would have been replaced with the new one.Alex K.
ocx contain many methods and events in it. and we only need a simple change on it. the change must be down when a date selection down ( ocx uses mscomctl2.ocx ) so if we can find an alternative for mscomctl2.ocx which we can change selected date base on our new formula, we can reach to our needs.Ashian

2 Answers

1
votes

There is another way, Safe to use only if you are owner of that ocx file. You can use vb decompiler to get source code from your ocx file so you can modify and create new source code. Here is a decompiler

http://www.vb-decompiler.org/

-1
votes

You can decompile OCX, use hooks, patch memory or completely rewrite it as mentioned in other comments and answers.

But first thing I'll try is make wrapper around your OCX. If your functionality replaces some functions or adds before or after, wrapper (AKA Proxy pattern) is the best choice.

Example of this method is DLLs around dx3d which uses OpenGL.