Maintaining one visible form with CF2.0
Hi,
I have recently created a CF2.0 Pocket PC application using VS 2005 Beta 2 after being inspired by the following white paper:
"Northwind Pocket Service: Field Service for Windows Mobile-based Pocket PCs"
available at:
When opening and closing all forms in my application I use the method used in the white paper which is described in an extract from the white paper below:
+++++++++++++++++++++++++++++++++
The code that runs when the first menu option (Plan) is selected looks like this:
Cursor.Current = Cursors.WaitCursor; PlanForm planForm =new PlanForm(this); planForm.ShowDialog(); |
During the load of the new form, the wait cursor is shown. Also note that the current form instance is passed as a parameter to the child form (PlanForm) to allow the child form to control the parent form's visibility.
This is what the PlanForm constructor looks like:
public PlanForm(Form parentForm) { InitializeComponent(); this.parentForm = parentForm; } |
The parent form instance is saved in a private variable (parentForm) that is used in the form's load event:
privatevoid PlanForm_Load(object sender, EventArgs e) { parentForm.Hide(); |
It is used to hide the parent form and remove the wait cursor. Also, it is used when the form closes:
privatevoid PlanForm_Closing(object sender, CancelEventArgs e) { parentForm.Show(); } |
The parent form is shown again. The reason for doing this is that there will be only one instance of the application in the current running programs list (Start > Settings > System > Memory > Running Programs).
+++++++++++++++++++++++++++++++++
This works fine for a CF1.1 application created in VS2003. However when I use the above method in a CF2.0 application, the application momentarily disappears when a form is shown. I think this is due to the load event running 'parentForm.Hide();' before the form that is being loaded is visible.
Please can someone help me out with this issue?
Best Regards,
Craig Harrison

