Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks


Welcome to the Mobile Line Of Business Blog

Tag Cloud


Post Categories


I had an interesting customer enquiry this week.     Our customer wants to have multiple Windows Mobile Line of Business applications running on the same device.    The interesting bit, was that they wanted to switch between running instances of each application.    i.e if you were in the warehouse module you could jump across to the QC application.      In my example as its a dedicated mobile application things like the start menu are switched off.   So what we needed was from a button in application 1,  we could switch across to application 2.         The other requirement was that we needed to switch between applications without exiting.

So here's the solution.    The first obvious bit was only to display launch buttons if the other application is installed on the device.

This was achieved by a simple file exist -

        const string testexename= @"\program files\ourfolder\ourexename.exe";

        private void frmmainmenu_Load(object sender, EventArgs e)
                  this.bttestexe.Visible = File.Exists(testexename);


OK, with me so far?


Next up,  behind our button we need to add code to either launch our other program we want to jump to,  or switch to an already running instance.

I came up with this behind the button

         string windowsname = "QC Scanning";
         Process.Raise(testexename, windowsname);

So,   we can either switch to a named window or launch the application.

To achieve this I created this 'Raise' static method as shown below

           public static void Raise(string exetolaunch, string windowtitle)
                IntPtr ourproce = FindWindow(null, windowtitle);
                if (ourproce == IntPtr.Zero)
                    // process not running so start it
                    System.Diagnostics.Process.Start(exetolaunch, "");



This is supported by a couple of pinvokes -

           private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);

           private static extern bool SetForegroundWindow(IntPtr hWnd);


So once put together we now have a very fast way to allow an end user to move between different applications, without even realising they are separate programs.

posted on Saturday, October 18, 2008 8:26 AM