First, I gave you bad (or at least incomplete) advice. I meant to say to use the Application.Idle event rather than the Load event. Calling Close from the Load event can cause a memory leak. You could do something like:
publicpartialclass MainForm : Form
InitializeComponent(); <br> <br>
// Code to determine whether to close form <br>if (ShouldClose)
Application.Idle += new EventHandler(Application_Idle);
} <br> <br>
void Application_Idle(object sender, EventArgs e)
The Hide and Close methods don't work in the constructor because the Form is still being constructed. And in any case you don't want to close the form at this point, assuming the calling code looks something like:
If MainForm is closed and disposed before it is constructed, then Application.Run will throw an ObjectDisposedException.
I have this Windows app.
When the user clicks on a button (any button), after the event handler is done, the form is supposed to have focus returned (like if there's a MessageBox involved).
However, I've noticed that the user is forced to click once on the form to regain focus.
To illustrate (and this sounds weirder)...
The user hits a button, a MessageBox appears saying "are you sure?", and the user hits "no".
The messagebox disappears. But the button still has focus (understandable). If the user clicks on a different button, that same button still has focus and Windows thinks the user just clicked it instead of the other button that they clicked. The user has to click once on the form (even though the form visually seems to have focus, with the title bar dark blue and everything) before clicking on any other button.
I have a method which is run as a thread and at the end of it I have:
XtraForm2 form2 = new XtraForm2();
and the thing is that the windows just flashes - opens and imidiately closes
how can I solve it??
Thread wat = new Thread(GetData);
// This next line is required since you're going to be // creating UI controls on the thread.
// This next line will prevent the application from exiting if the background thread is still running.
wat.IsBackground = false;
Let me ask you a question, though: why are you creating a new thread to create the form? You're creating lots of extra work for yourself by creating a new thread to launch the form. If you keep all the UI controls created on the same thread, things will be much easier for you.
Thus, I recommend you create all your UI controls on the same thread.
the application looks like this:
I start it, and there is a button which is pressed and then the method GetData is started as a thread and after it processes all the data a second window pops up with a report, so I don't make a new thread for the second window
greetings for all, I am very instered in learn how work with sound in c#...
for instance load a music file, see the frequency of that, if any one have any idea or better have a project as example, please tell my,
I believe in .NET 2.0 their is a System.Media namespace that has classes to handle wav sound files. If you are using .NET 1.1 or before (or if the classes in the System.Media namespace can't help you with your specific file format) then you might try using activeX controls. I know Windows Media Player has a control for video, but I am not sure whether they have a control for audio.
Now that I think of it, I remember somewhere on this site their is an article on audio output using Windows Media Player. Try searching.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
yes as you know, all word that we say, more or less, have a average in a frequency scale, but not wory, indeed I star now a project for do many things using this topic "sound", when I finish this a post that...
If you just want to play WAV sound files, you can use System.Media.SoundPlayer. If you want to do advanced things like changing the frequency of sound files, you'll need to go outside the .NET framework for that. You can use DirectSound, part of DirectX. You could probably also use DirectShow, which is part of the PlatformSDK. There are DirectShow wrappers for .NET on this site if you care to search the articles.
I have several MDI child windows for my application. These show up in the Windows list dropdown menu when I open them. When the user clicks on the X to "close" the child window, I just want to hide it so I capture this in my FormClosing event handler for each of them doing this:
if (e.CloseReason == CloseReason.UserClosing)
e.Cancel = true;
Which hides the child window just fine, however, when I want to redisplay it, clicking on the appropriate control to call Show() for that window, it displays just fine but I don't get an entry in my Windows list dropdown menu for that item.
Last Visit: 31-Dec-99 19:00 Last Update: 27-Jan-23 16:53