Link to home
Start Free TrialLog in
Avatar of phmurphy
phmurphyFlag for United States of America

asked on

Windows Mobile window/form switching

HI all,
I have a program called DataPoint written in C# with Visual Studio 2005, that runs on Windows Mobile devices.  I have two main screens, Project and Main.  I frequently need to get to a separate program via the Start button, then return to the DataPoint Project screen. If I then tap the button to take me to the Main screen I end up back at the last screen from the other program.

Rather than attach all of the solution files, can I get some conceptual guidance?

Here is how I can repeat the problem in the emulator.
1. Open up the emulator.
2. Open up the Calendar (Start>Calendar)
3. Open up DataPoint and get past the splash screen so you are on the
Project screen
4. With DataPoint still open, use the Start button to get back to the
calendar (Start>Calendar)
5. Leave the Calendar open and return to DataPoint (Start>DataPoint)
6. You should still be on the Project screen and now either tap the Green
GoTo Veg button or the Veg button on the bottom options line to get to the Main screen.
7. You will be taken to the Calendar instead of the Veg/Main screen.
8. To get to the veg screen tap Start> then select DataPoint from the list
of recently opened items, otherwise go to Start>Programs and select
DataPoint there. You will be taken to the Veg screen.

So instead to going to the correct screen, it goes to the Last screen that was open.

Avatar of hjgode
hjgode
Flag of Germany image

Hello

I am sorry, but I dont understand correctly.

If you like to switch to a specific window, use p/Invoke with FindWindow and ShowWindow (see pinvole.net). To run a specific app use System.Diagnostics.Process-Start (for example to start the calendar app).

I dont would go with using Start and then switch to the app you want.

Is Veg/Main another app or a form inside your main app?

regards

Josef
Avatar of phmurphy

ASKER

Thanks for your response.
Veg and Main are forms within the main app.  What is actually going on when I am collecting data is that I have to navigate to a location using GPS and a program called ArcPad, then when I get to a spot I need to collect vegetation data so I switch to DataPoint, fill in the project screen, then tap the goto veg screen and end up back at ArcPad instead.  Whatever program  that was running before I return to Datapoint is the one that the GoTo button sends me back to the first time I use it.  After I get to the Veg/Main screen via Start>DataPoint it works normally when switching back and forth between Project and Main.

I designed the DataPoint program and did some of the form layout work, but I have someone else do the actual C# programming.  They seem to be stumped with this issue so I am looking for some new approaches to the problem.
Hello phmurphy

sounds like the programmers dont use form hide/show correctly.

I recommend to include an option in the main app to start/switch to ArcPad (see Process.Start and FindWindow/ShowWindow pinvokes).

Then in your main app provide a button to switch to ArcPad

When switching forms inside the main app, always use form.hide for the actual form and form.show for the form to show. Pseudo code:

OnButtonVeg{
formDatapoint.Hide();
formVeg.Show();
}

If you dont hide the actual form, it may happen what you describe, you switch to another app and back and get the wrong form presented by the compact framework runtime.

It may also a good choice to use modal forms, i.e. if you are in the Project Screen and need to enter veg data for the actual data, use FormVeg.ShowDialog(). This ensures the project screen is locked until FormVeg is closed (returns with a DialogResult constant).

regards

Josef

Please attach some screenshots (see MyMobiler freeware, if you dont know how), if you need further assistance.
ASKER CERTIFIED SOLUTION
Avatar of phmurphy
phmurphy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Got a solution from a paid programmer.