1. Dexter Madrinan
  2. PowerBuilder
  3. Wednesday, 29 March 2023 15:10 PM UTC

Hi Guys,

 

We're facing some issues in a ribbonbar menu in which window activate event is always triggered when selecting a menu item? How do i prevent this? We need to put some controls in the window activate event to load enable/visible property to a ribbon items associated with the window.

 

I would appreciate your advice.

 

Best Regards,

Dexter Madrinan

Attachments (1)
Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Friday, 31 March 2023 22:58 PM UTC
  2. PowerBuilder
  3. # Permalink

If I were in your situation, here is what I would try:

  1. 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
  1. 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.

  1. 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

Comment
  1. John Fauss
  2. Monday, 3 April 2023 11:25 AM UTC
That is great news! Would you please mark this issue as resolved? Many thanks.
  1. Helpful
  1. Tomáš Podzimek
  2. Monday, 3 April 2023 11:46 AM UTC
I am not the author of this topic. I only had a similar issue. I've marked your answer as helpful.
  1. Helpful
  1. Dexter Madrinan
  2. Tuesday, 4 April 2023 14:03 PM UTC
Hi John,



Let me try your suggestion, then i will mark this issue as resolved.
  1. Helpful
There are no comments made yet.
Tomáš Podzimek Accepted Answer Pending Moderation
  1. Friday, 31 March 2023 08:36 AM UTC
  2. PowerBuilder
  3. # 1

Hi Dexter,

I ran into a similar problem. It's additionally combined with the use of Themes.
If setfocus() of a datawindow is called in the activate event of a form, the ApplicationButton of the ribbon or the menu of the LargeButton doesn't work.
If I remove setfocus() or turn off Themes, the ApplicationButton starts working.
I've tried to find some ribbon events to determine when the ribbon is active, but so far nothing has worked.

I would also need some solution.

Regards,

Tomáš

Comment
There are no comments made yet.
Peter Pang @Appeon Accepted Answer Pending Moderation
  1. Thursday, 30 March 2023 05:49 AM UTC
  2. PowerBuilder
  3. # 2

Hi Dexter,

 

Thanks for reporting this issue.

This issue is known internally at Appeon. Ribbonbar's Menu, ApplicationMenu, and Panel drop-down boxes are modeled after pop-up windows, so the current window's Deactivate event is fired when the drop-down box pops up, and the current window's Activate event is fired when it closes. Combobox does not.

I have submitted the problem to the development team for analysis again, please open a ticket for follow-up: https://www.appeon.com/standardsupport/newbug

 

Best Regards,

Peter

Comment
  1. Dexter Madrinan
  2. Friday, 31 March 2023 04:09 AM UTC
Hi Peter,



Yes, both of this event you mention is fired when Ribbon Menu is clicked, So, what advice you can give for us to handle this case because we need to set the visible/enable property when sheets are activated?



Would that be possible if you guys can prevent those event from firing while clicking the button associated with those menu items?



Best Regards,



Dexter
  1. Helpful
  1. Peter Pang @Appeon
  2. Friday, 31 March 2023 06:37 AM UTC
Hi Dexter,



Would that be possible if you guys can prevent those event from firing while clicking the button associated with those menu items?

A: This is the OS mechanism for windos, and we have no control over it.



what advice you can give for us to handle this case because we need to set the visible/enable property when sheets are activated?

A: I'm not sure about the use case of your app, please provide a simple reproducible case.



Or you can also try if the following works for you:

1. Replace the History dropdown menu with Combobox.

2. Control using Menu’s Shortcut.

3. In PB's own Example Graph app, w_mdi controls whether the Ribbonbar item is available through the Activate event of Sheet window. You can check and see if it is useful for you;



Best Regards,

Peter

  1. Helpful 1
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 30 March 2023 02:24 AM UTC
  2. PowerBuilder
  3. # 3

Hi, Dexter -

First, let me say I don't know the answer. However, I have some suspicions as to the cause.

Little has been publicly disclosed (as far as I know) about how PB renders the contents of a RibbonBar control from the source XML, but my suspicion is that it is a custom, frameless "container" window that behaves as if it is a control within a PB window. If this is the case, then that might explain why the (PB) window's Activate event fires immediately after you click on a RibbonBar item. I suspect the window's Deactivate also fires before the RibbonBar "activates".

So... if this is the way the RibbonBar control has been architected, there likely is not any way to prevent the window's Activate event from firing, since that is handled by the Windows O/S. It might be possible to utilize instance variables in the window in a way that would allow you to discern when the Activate event fires due to user interaction with the RibbonBar, but then again, it might not. I've not investigated it and have no immediate plans to do so.

Best regards, John

Comment
  1. Dexter Madrinan
  2. Friday, 31 March 2023 04:13 AM UTC
Hi John,



So in our case, What advice you can give for us to handle and retained back the ribbon bar item properties (eg. visible/enable) while switching a sheets window?



Best Regards,



Dexter



  1. Helpful
  1. John Fauss
  2. Friday, 31 March 2023 17:45 PM UTC
I have an idea that might work (no guarantees), but it will take me more time to explain it/type it up than I have available right now. I will try to find time this evening to respond.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.