1. Julian I.
  2. PowerBuilder
  3. Friday, 29 January 2021 12:08 PM UTC
Is there any method to change the menu of a window, for its original menu?
I am testing, but the changemenu() fails

// Reestablecemos el menú de la hoja activa
lw_sheet = w_frame.GetActiveSheet()
if isValid(lw_sheet) then   

    // Test: Pare eliminar el Menú (asignamos un menú Vacio)
    li_ret = lw_sheet.changemenu(m_vacio) --> Returns 1

    // Obtenemos el menú original de la ventana, puesto que el change menú lo cambia  
    ls_ventana = lw_sheet.className()
    lw_temp = create using ls_ventana
    ls_menu_original = lw_temp.MenuName
    if isNull(ls_menu_original) then ls_menu_original = ""
    destroy(lw_temp)

    // Reestablecer menú original creado dynamicamente
    lm_menu = create using ls_menu_original
    li_ret = lw_sheet.changemenu(lm_menu) --> Returns -1
   
end if

 

John Fauss Accepted Answer Pending Moderation
  1. Friday, 29 January 2021 15:43 PM UTC
  2. PowerBuilder
  3. # 1

Greetings, Julian - 

I don't know if this will work, as I have not tried it...

The MenuID property of a window is a menu object. Before you change the window's menu assignment, save a reference to the current menu in an instance variable to prevent Garbage Collection from destroying what would soon become an unreferenced object:

Menu imenu_original // Instance var

If IsValid(lw_sheet.MenuID) Then
   imenu_original = lw_sheet.MenuID
Else
   SetNull(imenu_original)
End If
lw_sheet.ChangeMenu(m_newmenu)

To restore the original menu:

Is IsValid(imenu_original) Then
   lw_sheet.ChangeMenu(imenu_original)
   SetNull(imenu_original)
End If

Maybe worth a try?

HTH

Regards, John

Comment
  1. Miguel Leeuwe
  2. Friday, 29 January 2021 16:43 PM UTC
I think this would be a question for support, we don't know what ChangeMenu() really does. It probably just looks in the list of libraries and ignores anything else, as far as I can see.
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 29 January 2021 16:50 PM UTC
What does work is:

m_whater_existing_menu_object lm_localMenuVar

...ChangeMenu(lm_localMenuVar)



weird ...
  1. Helpful
  1. Julian I.
  2. Monday, 1 February 2021 10:57 AM UTC
Hi Jhon,



With instance variable it fails too.



Regards

  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 29 January 2021 13:09 PM UTC
  2. PowerBuilder
  3. # 2

Hi,
Interesting. 
ChangeMenu() does not seem to work with a "instantiated menu variable".

What does work:

m_vacio   lm_variable
lw_sheet.ChangeMenu( lm_variable ) 

So, maybe you could do something like (just an idea, not an ideal solution):

// Reestablecemos el menú de la hoja activa
lw_sheet = w_frame.GetActiveSheet()
if NOT isValid(lw_sheet) then   
	return
end if

choose case lw_sheet.Classname()
	case "w_sheet1"
		lw_sheet.changemenu(m_sheet1)
	case "w_sheet2"
		lw_sheet.changemenu(m_sheet2)
	case "w_sheet2"
		lw_sheet.changemenu(m_sheet3)
end choose

regards

 

 

Comment
  1. Miguel Leeuwe
  2. Monday, 1 February 2021 11:20 AM UTC
Hi Julian,

It sounds like a redraw problem and it looks like you are using a Theme?

Would it be possible to install a version without theme (just to test)?

regards
  1. Helpful
  1. Julian I.
  2. Wednesday, 3 February 2021 06:46 AM UTC
Hi Miguel,



It could be because CITRIX has migrated from Windows Server 2008 to Window Server 2016. With 2008, the "Themes" were not applied (they did not work) and now they do.



We will test it,

Thank you very much.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 3 February 2021 08:35 AM UTC
I'm looking forward for the outcome! We also have customers on Citrix, but no themes (yet) here.

regards
  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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.