Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1745
Can I use one FormManager for all my modal dialogs?
posted

I have about 20 modal dialogs and no dialog displays another dialog so there is never more than one displayed at a time.

I would like to create a single UltraFormManager to handle all these dialogs (only 1 at a time) by assigning the current dialog to the FormMgr.Form property.

eg. Create the dialog
      assign it to the Form property
      Display the dialog using ShowModal()

I tried this by defining an UltraFormManager on my MDI form - but NOT assigning its Form property to the current form. (I can not use it with the MDI form because that already has a DockManager which I read would be a conflict.)

I then use the code indicated above and it 'almost' did what I wanted.
It displayed the new caption and border - but within the dialog's client area instead of on top of the Caption/frame.

Every dialog already has a panel that uses Dock Fill (as required by the FormMgr) so I thought it would be able to figure out the increased size and position changes.

Did I miss a step, or is this simply not possible? 

Thank
Mike 

Parents
  • 1745
    Offline posted

    The following appears to work correctly. It requires a few odd things to be done in a very specific order  but it does work.

    Create a 'common' FormManager (in your main form) using code.

    Add the properties:
            Friend FormMgr = New Infragistics.Win.UltraWinForm.UltraFormManager()
            Private Dock_Area_Left = New Infragistics.Win.UltraWinForm.UltraFormDockArea
            Private Dock_Area_Right = New Infragistics.Win.UltraWinForm.UltraFormDockArea
            Private Dock_Area_Top = New Infragistics.Win.UltraWinForm.UltraFormDockArea
            Private Dock_Area_Bottom = New Infragistics.Win.UltraWinForm.UltraFormDockArea

    and initialize them in Form_Load:
            Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinForm.DockedPosition.Left
            Dock_Area_Left.FormManager = Me.FormMgr
            Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinForm.DockedPosition.Right
            Dock_Area_Right.FormManager = Me.FormMgr
            Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinForm.DockedPosition.Top
            Dock_Area_Top.FormManager = Me.FormMgr
            Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinForm.DockedPosition.Bottom
            Dock_Area_Bottom.FormManager = Me.FormMgr

    For each modal dialog:
        Set the FormBorderStyle to FixedDialog or Sizeable (in the Designer)
        Add a Panel with Dock=Fill if you do not already have one.
        If the border is FixedDialog make the panel/form 8 pixels wider and 33 pixels higher
            than it used to be. (allows for the frame and caption)
        Add the following 2 lines to the Form_Activate event handler:
            MainForm.FormMgr.Form = Me
            Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None

    Note - If you initially define the dialog with FormBorderStyle=None
               then the Close button on caption will not work.

    This method is a whole lot easier than adding 50 LOC to every Designer file and an additional 75 LOC in the associated resx file (if your app is localizable)


    The only remaining problem is those Forms that already have an UltraToolbar control.

     If the toolbar is not moveable or customizable it seems that the Dock areas it defines are redundent ... so maybe a Form Manager can be forved to work there also.

    If anyone gets that to work please add the required info to this thread.

    Thanks
    Mike

Reply Children