If I were in your situation, here is what I would try:
- Create a global Longptr variable that will be used to hold the handle of the most-recently-deactivated window:
// Handle of the most-recently-deactivated sheet window.
Longptr glp_mrdw_handle = 0
- Every sheet window (hopefully, you have a sheet window ancestor) will need the following statement in its Deactivate event:
glp_mrdw_handle = Handle(This)
If you don't have an ancestor sheet window object, put that statement in every sheet window's Deactivate event.
- In the Activate event of every descendant sheet window where you are messing with the RibbonBar configuration, do this first:
If Handle(This) = glp_mrdw_handle Then Return 0
.
. (normal Activate event code)
.
Summary: Any time a sheet window deactivates, the new global variable will hold that window’s handle. When a sheet window activates, the activating window’s handle is compared against the most-recently-deactivated sheet window’s handle and if it’s the same, there’s no need to perform any RibbonBar customization. If the handles are different, then the RibbonBar customization is performed.
I suggest you verify this works by only updating a small number of windows and testing.
Best regards, John
Let me try your suggestion, then i will mark this issue as resolved.