News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How to avoid multiple entries in the task list for the .Net application?

By Andrey Lebedev, November 10, 2003.
Print version

Question

If the .Net Compact Framework application shows dialogs via ShowDialog method each dialog is displayed in the tasks list as a separate application. How to avoid multiple entries in the task list for the application?

Answer

Here is how this looks like:

I don't know if there exists a correct way to do this but there is a trick that solves the problem. Explanation: each dialog in .Net application is a top-level window without parent therefore it is shown in the tasks list. The first (wrong?) idea was to assign the parent window (via either Windows API or .Net capabilities) to each created dialog as native application does. This approach didn't work at all. The second idea was to hide the calling window before displaying the dialog and to show it back again before the dialog exits. This approach worked perfect if the parent hid itself in the child's Paint handler (no other event handler managed to provide the required behaviour) but in some dialogs Paint is never called because the dialog's surface is obscured by child controls.

The third and last idea was to assign an empty caption to the calling window before displaying the dialog and to restore the caption when the dialog exits. There is even no need to save the window title because according to the common agreement each window and dialog in the mobile device application has the same caption - the title of the application. For example, if the application class is declared as MyApp then add to this class a public constant string value - the application title:

class MyApp { ... public const string APP_TITLE = "My app title"; ... }

then for each ShowDialog use the following code:

Text = ""; dlg.ShowDialog(); Text = MyApp.APP_TITLE;

Done!

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House