aewarnick Posted April 24, 2003 Posted April 24, 2003 I cannot use Hide() or the visible property in the constructor or Load() to hide my form when it is initializing. I cannot leave out the constructor code because this program runs in the background. The form needs to be initialized but I don't want the user to see it until they click the notify icon. Quote C#
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 Does this have anything to do with Deployment? (Maybe I misunderstood the question) Quote Visit...Bassic Software
aewarnick Posted April 25, 2003 Author Posted April 25, 2003 When the user opens the exe file I don't want it to show the form but a notify icon will be in the taskbar for the user to Show() the form with. Quote C#
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 Do you want this as part of a distribution package? I think I still don't understand. Quote Visit...Bassic Software
aewarnick Posted April 25, 2003 Author Posted April 25, 2003 I don't understand the question about a distribution anyting? Quote C#
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 Is your problem/question related to running your application on your own computer or on being able to run it on other machines... While the other machines do Not have Visual Studio .Net installed? Quote Visit...Bassic Software
aewarnick Posted April 25, 2003 Author Posted April 25, 2003 Ohhhhh hhhh h! It will be distributed to anyone and I think it will be free too. They will most likely not have VS. Quote C#
Cassio Posted April 28, 2003 Posted April 28, 2003 I guess Robby was saying that it would be better if you posted this question in the Windows Forms area, since it has nothing to do with deployment. Quote Stream of Consciousness (My blog)
Moderators Robby Posted April 28, 2003 Moderators Posted April 28, 2003 Cassio is dead on. :) I'm still waiting for aewarnick to confirm this. :( Quote Visit...Bassic Software
aewarnick Posted April 28, 2003 Author Posted April 28, 2003 (edited) Maybe divil would be so kind as to move the thread for me...I don't want to post this twice. Edited April 28, 2003 by aewarnick Quote C#
TreasonX Posted April 29, 2003 Posted April 29, 2003 Well anyway the answer to hiding the form on startup is. Set the windows state to minimize on startup Hide it from the task bar then when you show the form restore the windows state to normal then show Thats the easiest way I have found to do it. Quote
aewarnick Posted April 29, 2003 Author Posted April 29, 2003 Thanks TreasonX. I already tried that. The problem is that the form is still accessable to the user that way. All they have to do is use Alt + Tab to veiw any open form in windows. There has got to be a better way. Quote C#
TreasonX Posted April 30, 2003 Posted April 30, 2003 Okay here is the best thing I can come up with on start up minimize and hide from task bar. set formBorderStyle to FixedToolWindow this hides it from alt tab. It works.. but it doesnt seem like the best way. If you find something better give me a holla :) credit for this information goes to: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69213&highlight=alttab Quote
aewarnick Posted April 30, 2003 Author Posted April 30, 2003 Thanks Tx, I will probably make my own class with methods called show and hide to handle those things form my forms. Quote C#
aewarnick Posted April 30, 2003 Author Posted April 30, 2003 Setting it no None border works as well. Quote C#
Winston Posted April 30, 2003 Posted April 30, 2003 i tired getting that to work same problem as u so i used a OnPaint event and hide the form my app paints the panel so i just used a boolean and set it to true once it had hid the form on startup once and then on exit set it back to false so that it will work the next time Quote
aewarnick Posted May 1, 2003 Author Posted May 1, 2003 Thank you, winston, I will remember that. Quote C#
aewarnick Posted May 12, 2003 Author Posted May 12, 2003 Hey guyyyyysss!! I found the answer to this question and it is muuuuuch better than minimising the form and hiding the taskbar box. I was looking and reading some info here: http://www.syncfusion.com/FAQ/WinForms/ and found out about this great resource in VS help: search for this: Setting a Form to Be Invisible at Its Inception Now, the problem is that I need to know if windows is closing the form or if the user is because windows will not restart when the form is running unless I use Application.Exit(). How can I tell how the form is being closed? Quote C#
*Gurus* divil Posted May 12, 2003 *Gurus* Posted May 12, 2003 There's a reason why that FAQ is permanently posted at the top of this forum ;) You can listen for the SystemEvents.SessionEnding event to tell when the user is trying to log off or shutdown the system. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted May 12, 2003 Author Posted May 12, 2003 Gotcha! Now it's in 2 places! Thanks divil. Quote C#
aewarnick Posted May 12, 2003 Author Posted May 12, 2003 Have a problem. private void UserShutdown(object sender, SessionEndingEventArgs e) { MessageBox.Show("exit"); Application.Exit(); } //------------------------------- private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel=true; this.Visible=false; MessageBox.Show("closed"); } Here is what happens in the background (I beleive). The user attempts to restart the computer. First the Form1_Closing ev is called. It cancels the close event, making windows stop shutting down. Because of that, the UserShutdown ev is not called at all. How can I tell from the Closing ev that the user is trying to shut down? Is there a way I can wait on that event? Or maybe there is another way? What do you think? Quote C#
*Gurus* divil Posted May 12, 2003 *Gurus* Posted May 12, 2003 Hmm, that's weird. If the Closing event is fired before the Shutdown event, I don't know what to tell you. Come to think of it, try checking Environment.HasShutdownStarted in your Closing event, perhaps that'll do it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted May 12, 2003 Author Posted May 12, 2003 (edited) The command HasShutdownStarted must be VB because it is not there. Nevermind, it is not static. I think that is why it was not in the list. I will try it. Edited May 12, 2003 by aewarnick Quote C#
aewarnick Posted May 12, 2003 Author Posted May 12, 2003 (edited) private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Environment E=new Environment(); MessageBox.Show( "closed "+E.HasShutdownStarted ); e.Cancel=true; this.Visible=false; } I get this error: D:\My Documents\C Sharp projects\WallPaperRotator\Form1.cs(873): 'System.Environment.Environment()' is inaccessible due to its protection level Edited May 12, 2003 by aewarnick Quote C#
*Gurus* divil Posted May 12, 2003 *Gurus* Posted May 12, 2003 HasShutdownStarted is static. Use System.Environment.HasShutdownStarted. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.