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?
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 a
CheckBox. The default property of the
CommandButtonis actually the
Valueproperty that indicates whether a button is toggled. By setting the property, the
Clickevent is generated. This is done even if the button is not styled as a
ToggleButtonand therefore doesn't change its state.