Form.ShowDialog in Compact Framework



Within the Compact Framework, many methods and classes you’re used to working with in the Desktop Framework have been removed. One of these is the ShowDialog() method with the form’s owner as a parameter.



If no owner is supplied, the .Net Framework will take the uppermost form as the parent and apply this to the new form being shown. This is not ideal in all cases. In our application, we utilize Symbol’s (now Motorola’s) AppCenter. This application renders a control bar across the bottom of the screen that is always on top, thus assuming parental control over the newly created child form. This behaviour is incorrect and can lead to problems.



To combat this, I created a base form, from which all forms in the application are inherited from and added the following method;




  Public Overloads Function ShowDialog(ByVal FormOwner As Form) As DialogResult


    Me.Owner = FormOwner


    Return MyBase.ShowDialog


  End Function





This method now allows me to call the ShowDialog method with a parent form parameter as I do in the Desktop Framework.



Comments