Functions keys stop working when a form is undocked

Posted by Larry Reed on 15-Jan-2016 13:24

We are using Progress 11.5.1.011 64 bit with the Infragistics controls and are using SmartComponents from Consultingwerk.

Our application has all our functions (forms) opening as mdichild forms inside our main menu form.   We are using the Infragistics UltraToolBarsManager in our forms with some button tools.  We have "MdiMergeable" set to true so we can have the ribbon from the individual forms merge with the main menu ribbon.  We've also mapped all of the buttons to Function keys.  The "Add" button is mapped to "F5", Save is mapped to "F2", etc.  These all work fine when the form is first opened as an mdichild.   When we undock the form, the function keys stop working. 

Has anyone run into this kind of behavior?  This is some of the code that is in our DphsWindowForm which we use as a base for all the forms.  Basically in the Onload of the form we're running a method to map the function keys to the buttons.  When we un-dock the form we are running the same code to reset the function keys.  Onload only runs when the form is initially opened and not when it's docked or undocked and we thought the functions keys needed to be remapped.   I'm not sure what other specifics would be helpful.  Mostly wondering if anyone has run into this kind of issue before.

METHOD PROTECTED OVERRIDE VOID OnLoad (e AS System.EventArgs ):

/* this is how we would set the shortcut key for buttons.

We need to add the specific "Key" values for the buttons in the case statement along with the shortcut key */

THIS-OBJECT:SetShortcutKeys(oToolbarController).

END METHOD.

METHOD PUBLIC VOID SetShortcutKeys(poToolbarController AS Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ):

IF VALID-OBJECT (poToolbarController) THEN

DO:

SetShortcut ("TableIOSave", System.Windows.Forms.Shortcut:F2, poToolbarController).

SetShortcut ("TableIOCopy", System.Windows.Forms.Shortcut:F4, poToolbarController).

SetShortcut ("TableIOAdd", System.Windows.Forms.Shortcut:F5, poToolbarController).

SetShortcut ("TableIODelete", System.Windows.Forms.Shortcut:F6, poToolbarController).

SetShortcut ("TableIOUpdate", System.Windows.Forms.Shortcut:F8, poToolbarController).

SetShortcut ("TableIOCancel", System.Windows.Forms.Shortcut:F10, poToolbarController).

END. /* if valid-object toolbarcontroller */

 

Reset the function key mapping when form is undocked

METHOD PRIVATE VOID ToolbarToolClickHandler (sender AS System.Object,

e AS Infragistics.Win.UltraWinToolbars.ToolClickEventArgs):

 

CASE e:Tool:Key :

WHEN "Undock":U THEN DO:

IF e:tool:SharedProps:Caption = "UnDock Form" THEN DO:

/* this doesn't appear to be working properly. We think it's too early and that the tool bar

for the undocked form isn't there yet but not sure where to put this. */

IF TYPE-OF (sender, Consultingwerk.SmartComponents.Implementation.SmartToolbarController) THEN

oToolbarController = CAST (sender, Consultingwerk.SmartComponents.Implementation.SmartToolbarController).

ELSE

oToolbarController = Infragistics.Win.UltraWinToolbars.UltraToolbarsManager:FromForm (THIS-OBJECT) .

THIS-OBJECT:SetShortcutKeys(oToolbarController).

END.

END CASE.

END METHOD.

 

All Replies

Posted by Mike Fechner on 16-Jan-2016 03:14

Let me start with two assumptions:

a) When you say "undocking" a form, you actually set the child forms MdiParent property to ? at runtime. Causing the Form to be re-realized as a stand along form.

b) Your SetShortcutKeys method contain a couple of statements like this here:

ultraToolbarsManager1:Tools["ButtonTool2"]:SharedProps:Shortcut = Shortcut:F7 .

Then I'm able to reproduce this in a very simple test case. I must say I am not surprised that this "can" happen. 

First you must understand, that when you "undock" the Form, the .NET Framework actually recreates the Form. The Form's "Handle" (the reference to the Form in the Windows Desktop API) is a new one and all .NET Controls on the form have to become recreated as well. 

Secondly, when the MdiMerging of the UltraToolbarsManager is used, you are actually not interacting with the MdiChild UltraTooblarsManager at all. All the buttons, Ribbon Bands, etc. are shadowed on the MdiParent's band. 

So after undocking you are actually dealing with the Ribbon of the MdiChild for the first time (on actually a new Ribbon on a new form).

I tried fixing the issue by re-assigning the function key after "undocking" the form. This does not change anything.

So it seems that the issue is not caused by Infragistics potentially losing the function key properties along the way. Sounds more like they are not getting registered against the new Windows desktop resources that were created after "undocking" the form (new Form, new Ribbon).  Sounds like an Infragistics issue to me. But they may respond that it was never intended to work that way at all ... when you talk to them you should be clear that you are divorcing an MdiChild form it's MdiParent. "Undocking" has a different meaning for them (related to the UltraDockManager which you are not using in this scenario; and anyway Ribbon in dockable panes and UltraDockManager don't play together at all).

What obviously works as an alternative to the "Shortcut" key definitions is the KeyPreview functionality of the form. That works for the MdiChild Form before and after your "undocking".

https://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview(v=vs.110).asp

You'll receive all key events in the form in the form's KeyDown event. From the Form itself and all controls in the Form. 

There are two drawbacks:

a) It may get called very often (client.log file get's polluted)

b) Users won't see the function key assignments in a menu or context menu next to the menu item label (right aligned). You may add them to the actual label (which would be left aligned).

So when this undocking is important for your piece of mind, I'd get in touch with Infragistics tech support (directly or through PSC) and see if they are willing and able to get this fixed. 

Posted by Larry Reed on 16-Jan-2016 07:48

Mike,
 
Your are correct in that we are setting the MdiParent property to ? and not involving the UltraDockManager for this activity.
 
We also tried re-assigning the function keys when the user selects to "undock" the form and even placed a button on the form to set the function keys when the form is undocked and this did not work.  We also noticed that if the form starts out undocked the function keys work fine.  Then you can dock / undock as much as you want and everything works fine.  It's only when the form is initially launched as an MdiChild that we have issues.
 
I do have a ticket open with Progress Tech Support. They provided this link which seems to be discussing the issue we are having and we need to go through it and see if there is a solution.
 
I also have scheduled to do a session with them at 2:00 on Monday so they can look at this for me. 
 
Thanks,
 
Larry
 

This thread is closed