I have a vb6 form with an ocx control on it. The ocx control has a button on it that I want to press from code. How do I do this?
I have:
Dim b As CommandButton Set b = ocx.GetButton('btnPrint') SendMessage ocx.hwnd, WM_COMMAND, GetWindowLong(b.hwnd, GWL_ID), b.hwnd
but it doesn’t seem to work.
I believe the following will work:
CommandButtons actually have two functions. One is the usual click button and the other is a toggle button that acts similar to aCheckBox. The default property of theCommandButtonis actually theValueproperty that indicates whether a button is toggled. By setting the property, theClickevent is generated. This is done even if the button is not styled as aToggleButtonand therefore doesn’t change its state.