Why doesnt this work
-
I have a Windows application and I was doing something that I thought to be very simple. The ONLY change that I made was:
/// The main entry point for the application. /// [STAThread] static void Main() { Form1 someForm = new Form1(); someForm.Visible = false; Application.Run(someForm); }
This didnt work. I dont know what I am doing wrong; I would have thought that that was a pretty good way to make it invisble but Im wrong. Thx, Jim -
I have a Windows application and I was doing something that I thought to be very simple. The ONLY change that I made was:
/// The main entry point for the application. /// [STAThread] static void Main() { Form1 someForm = new Form1(); someForm.Visible = false; Application.Run(someForm); }
This didnt work. I dont know what I am doing wrong; I would have thought that that was a pretty good way to make it invisble but Im wrong. Thx, Jim -
You need to make changes to your form in your onload or constructor...not in the Main. Have a wonderful evening Doug Wright Developer, TDCI
-
I have a Windows application and I was doing something that I thought to be very simple. The ONLY change that I made was:
/// The main entry point for the application. /// [STAThread] static void Main() { Form1 someForm = new Form1(); someForm.Visible = false; Application.Run(someForm); }
This didnt work. I dont know what I am doing wrong; I would have thought that that was a pretty good way to make it invisble but Im wrong. Thx, JimApplication.Run(Form f)
sets the form'sVisible
attribute toTrue
internally when it's starting the message loop for the form, so your form gets displayed regardless of what you setVisible
to. To hide the form from the user you can either set its size to (0,0) or move the form off-screen (or both). Regards, mav -
Application.Run(Form f)
sets the form'sVisible
attribute toTrue
internally when it's starting the message loop for the form, so your form gets displayed regardless of what you setVisible
to. To hide the form from the user you can either set its size to (0,0) or move the form off-screen (or both). Regards, mav -
Thanks a lot, but sadly I tried that too with no result :( More exactly, this was the code that I used:
public Form1() { this.Visible = false; InitializeComponent(); }
I also triedpublic Form1() { InitializeComponent(); this.Visible = false; }
What about the Form's Load method? That was the other suggestion, did you try that?
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
Thanks, I didnt know about that side effect! This program is going to be run as a scheduled task, how do I go about stopping it from stealing focus? Thanks a lot, Jim
You don't have to show a form for your program to run and perform its tasks. Take a look at the other
Application.Run()
overloads, that could be the cleaner solution. Otherwise you'd have to p/invokeShowWindow()
, there you can specify to show a window without giving it focus. Regards, mav -
You don't have to show a form for your program to run and perform its tasks. Take a look at the other
Application.Run()
overloads, that could be the cleaner solution. Otherwise you'd have to p/invokeShowWindow()
, there you can specify to show a window without giving it focus. Regards, mav -
I have a Windows application and I was doing something that I thought to be very simple. The ONLY change that I made was:
/// The main entry point for the application. /// [STAThread] static void Main() { Form1 someForm = new Form1(); someForm.Visible = false; Application.Run(someForm); }
This didnt work. I dont know what I am doing wrong; I would have thought that that was a pretty good way to make it invisble but Im wrong. Thx, Jim