One possible way to accomplish this is by using the DYNAMIC keyword when triggering an event in the parent window.
Attached is a simple custom visual user object (CVUO) I threw together to illustrate. I used command buttons instead of picture buttons:
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAe0AAAAoCAIAAABchDUfAAAHbklEQVR4Ae1d25WrOBAkJ2dDBo7CqTgBB+FQfG4Ck8Hco0c/JNGYBswALj7WopFEV1V3gb2zZ7tfHGAADIABMHBABq7X6088ut/f3384wAAYAANg4FAM3O/32sc7HGAADIABMHAcBuDjx9EKmYIBMAAGhhiAjw+xghgYAANg4DgMwMePoxUyBQNgAAwMMQAfH2IFMTAABsDAcRiAjx9HK2QKBsAAGBhiYJKPP857DHHSnRfuA3i77uv0/ULI39bCU338dcbj8TB97YxwX8CbHmOPx+Or9E0+/lWQv01i+PjAG+q3FQHwnsPjrOc0fPwc+r5e5qsYfBw+Hn5nOE2hayCWr30bXvi4ropDj62Sho/Dx+Hjh25tSd5qcvi4cHTwkSUxfBw+Dh8/eHNT+laTw8eJocN/WhLDxz/s48/b5XJ76vppI/rqJ8dWESz9neHvEI2z9Sm843f9u6sWXvj4Ik32VN6WxNv6+PN2IduszG0R0XMXW6T4fS0CG4TUFkEVUZx03eAWc+E169x4i9y6/t7smAIVIj1r5BJPK+6yJgNuvJzSvEEFtjqdt6dnlYV3HR8vZLKLwZPw8rkWZEcLK1yh+FrV2sjyvOfuYOHd0sfvvfjUvTddYS5E/zqLFEcRpJsGpfu+fvGO19oiqCL6NJTUB3lx461zM5LT0yoVRi7xTD1nVQbceDmleQMN5PUacIR5205eZeFdzcf5IRu974OVuhjy5BaeYEqVrJNz+8RES+KNfbyWvnoWhtIXr7j3aSyTuI7WocgiZXIR5DSS0LoiIpDyq4egKF+7iyohyMkF8gaRNJ4mFD1vl5rPcV7cePmmaV8+FSxRESuuWMhvOhlRqSMvD3dZkwE33nH63l4tgJCPh2Df0/dQn2Bv71hOsPCu7+P6KSXFMFqokZxbr2u6zH7WmQV5cgureksJsIiCixpWIm3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4dkJ9WHZnokraP9yXt04NPMfSLLxb+nhN4Z+fW6RMLoI/R+BLAHhT62yqr25en1zu2Za+6/i4O50tFliQN5V4IlBl9BNXtNMsvPBxecfg0R6LoJXUH7GKAHj9XE5eAR+fTNWMiQcq6eqn8RlgR35CgI+ze8sAvjavyPa26kBNvgp1Fl68j69C7x42sSSGj4t98wg+voeSXZ6DVfTfpi98fHkt7WQHq6Th4+zeMvi2PgfenXTpwjSsJoePLyR2P8stiaf6+Fn/f3di3mp0VrBWEQDvaRhQVVwMTwOwBVLgpJN22mkiBLH4nOTjxQqcgAEwAAbAwJ4YgI/vSQ3kAgbAABjwMwAf93OGFWAADICBPTEAH9+TGsgFDIABMOBnAD7u5wwrwAAYAAN7YgA+vic1kAsYAANgwM8AfNzPGVaAATAABvbEQO3jdxxgAAyAATBwNAau1+tPPLorDjAABsAAGDgmAz/x6NIH/gkGwAAYAAMHZQA+flDhkDYYAANgIDPwH8eTXvuHWb4wAAAAAElFTkSuQmCC)
The CVUO contains a single instance variable:
Protected:
Window iw_parent // Reference to the parent window (populated in this object's Constructor event).
It also contains a function named of_GetParentWindow:
// Public Function of_GetParentWindow(REF Window aw_Parent) Returns Integer
// Finds a reference to this object's parent window.
// Argument(s):
// Window aw_Parent [by ref] This parameter will be assigned a reference to
// the parent window.
//
// Returns: Integer 1 -> Success.
// -1 -> Failure.
// Usage notes:
// 1. If no parent window can be found, aw_parent gets set to NULL.
// Attribution: The logic is taken from the PowerBuilder Foundation Class (PFC) objects.
PowerObject lpo_parent
// Obtain a reference to this object's immediate parent.
lpo_parent = This.GetParent()
// Do we have a reference to a window object?
Do While IsValid(lpo_parent)
If lpo_parent.TypeOf() = window! Then Exit
// No - Continue up the parent hierarchy until a window is found.
lpo_parent = lpo_parent.GetParent()
Loop
// Do we have a valid window reference?
If IsNull(lpo_parent) Or Not IsValid(lpo_parent) Then
SetNull(aw_parent)
Return -1
End If
// Assign parent window reference to the argument parameter.
aw_parent = lpo_parent
Return 1
and code in the Constructor event script to call the function to save the reference to the parent window in the instance variable:
// Constructor event.
// Obtains and saves a reference to this object's parent window (for use by the command buttons).
Integer li_rc
li_rc = This.of_GetParentWindow(This.iw_parent)
Return 0
For the menu (command) buttons, the code triggers an event in the parent window. Here's the code from the "sideways" menu button:
// Clicked event.
// Trigger an event in the parent window.
If IsValid(iw_parent) Then
iw_parent.EVENT DYNAMIC ue_sideways()
End If
Return 0
The clicked event in the other buttons are similar.
Take special note of the "DYNAMIC" keyword (it does not have to be in uppercase). This tells the compiler to defer binding this function call to the referenced object until execution time. If the referenced object (the parent window, in this case) does not contain the specified event, the event call fails silently. Without the DYNAMIC keyword, the code in the clicked event could not be compiled.
Unzip the source for the CVUO and import it, then add it to a window. Add any/all of the user events called by the menu bar's buttons (ue_save, ue_addrow, ue_deleterow, ue_up, ue_down, ue_sideways) to the window. I tested by coding a MessageBox function call in the ue_sideways event.
I don't know if this technique will work for you, but I hope it helps.
Best regards, John