Jump to content

Hide main form/application and showing it again


Guest MehulAmin

Recommended Posts

Guest MehulAmin

I am trying to hide my form using .Hide() and want to show it again on a timer later using .Show(). The Hide() works fine but when I do a .Show() it does not show my application form. I have tried the following suggestions from other threads regarding this matter but in vain:

+ setting title to "" to hide the form and setting it back to show it

+ using .Visible to set to false and true

+ using .BringToFront() , .SetFocus()

I have made sure my timer stuff is working as I have a breakpoint and I hit it.

Anyone has any ideas? My other concern is that when my application is running and someone presses the "Home Screen" button and then reselects/relaunches my application nothing happens. :oops:

I am using Smartphone SDK 2003 and .Net CF

Link to comment
Share on other sites

I don't fully know what you are trying to do, but when my main form spawns a modal child form, I have the child form set the parent's .Visible to false during the onload and to true on the OnClosed. This solves the Home screen button in my case.

Link to comment
Share on other sites

Guest MehulAmin

The application on a timed basis performs some updates and then tries to display the informaion in the form. After it starts up for the first time it displays its initial information then does a .Hide() and starts the timer. When the timer goes off it tries to do a .Show() etc. but the form does not appear.

Link to comment
Share on other sites

What you are trying to do seems to go against some of the UI guidelines. You run the risk of stealing the focus from other applications that the user may actively be using. For example, the user may be composing a SMS message, and suddenly your window pops up in the middle of their keypresses.

You should also think about what would happen if the user is in the middle of a phone call, and your window pops up. Granted, the phone may be up against their face at the time, but if they wanted to switch to speaker phone, see the caller ID of another incoming caller, enter a new contact, all while still on the phone call, stealing the focus may upset the user.

If you still want to go ahead with your originally desired behavior, try this code. You may need to remove your code that sets the title to ""

[DllImport("coredll.dll")]

public static extern bool SetForegroundWindow(IntPtr hWnd );

[DllImport("coredll")]

public static extern IntPtr FindWindow(string className, string wndName);

this.Show();

IntPtr hwnd = FindWindow(null, this.Text);

SetForegroundWindow(hwnd );

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.