I want to show an loading image when i launch my desktop application. can anybody tell me how to show this in C#? Results required as happens in visual studio 2005/2008 when we launch this application.
What you are looking for is actually a splash screen. Look at this codeproject article. It explains really well how you should do this.
http://www.codeproject.com/KB/cs/prettygoodsplashscreen.aspx
What i did in my previous project was, that make the Form1 (display form) and make it wait for a while, then close it after that launch the Form2 which is the actual application.
But that was way back when i was a fresher. Now what i might do is, have a Form1 which ill launch and in the backgroundworker do all major UI processing work such as if any loading of data needs to be done, etc stuffs and keep every thing ready in memory. Then ill close the Form1 or make it hide or invisible and launch the Form2 which is the main app form and pass all the information required to it.
Related
Sorry, this more than likely has been asked at some point but I'm not even sure what I should be searching on...
I have a winform application with multiple forms. Up until this point having a one form open at a time has been fine. But now, I have a new form that I want to add on but have the ability to keep that form open while I work in other forms. I'm not even sure what this is called but I have seen it done before in other applications.
I did find this: Run two winform windows simultaneously
But this new window is a winpipe queue viewer that runs a thread. When I try initializing using the
Application.Run(new QueueViewer());
I get the error:Starting a second message loop on a single thread is not a valid operation. Use the Form.ShowDialog instead.
The problem with that is it locks the program from doing anything else until I close that form.
Thanks for your help!
Add a form to your project (let's call it Form2). Somewhere within your code (maybe in a button click event) use the following code:
Form2 f = new Form2();
f.Show();
The Show method allows you to interact with the originating form, whereas ShowDialog prevents interaction from the original form.
I'm currently doing a security assessment of an extremely large C# application. I have wrote a tool to help me do the assessment that also runs in C#. The entire application uses ShowDialog aka modal forms. I'm trying to come up with a way where I can still use my tool (click on it for example) while modal dialog boxes are popped up. I figure, this may require another thread or something else. If anyone has any easy tips on a way to make it so that my form doesn't get blocked by ShowDialog, that would be great.
The entire purpose in using a modal dialog is for it to block it's parent until it is dismissed.
We have a Windows Form application for our fingerprint scanning for time keeping and it takes too much time for just initializing the control for the finger print scanning, around 5 to 10 minutes. So we need to create a loading form so that users will know that the application doesn't hang and they need to wait, but the cause of the long running process was inside the InitializeComponent() method from the initialization of the form.
My question is, how can I move the InitializeComponent() method to another thread so that I can show a loading form while initializing the form where the biometrics scanner control is, because it creates an error when accessing a UI control from another thread other than the main thread?
My code is in C#, Framework 2.0, build in Visual Studio 2008.
Please help, thanks in advance.
You can remove your control for the finger print scanning from the visual designer and create this control from the code using an additional background thread and writing a progress information during this process.
SO has lot of data about it:
How to update the GUI from another thread in C#?
Accessing UI in a thread
Best Way to Invoke Any Cross-Threaded Code?
you can find a lot more.
If still need help, post a comment.
You can find your InitializeCompoent(); method in yourForm.designer.cs, and from there you can modify it.
I have tried using this code sample:
private void DoShortRunningTask()
{
using (new StWaitCursor())
{
Thread.Sleep(5000); // 5 sec delay.
.. do some work ..
}
}
From: http://www.codeproject.com/KB/cpp/WaitCursor.aspx
But it did not do anything for me, since I did not have a main form. I do not need a main form. My C# project type is Windows Application, but the only GUI it shows if any is error or success messages dialogs. Is there a way for me to fake the existence of a WinForm (so that it exists but is not visible)? Would the mouse cursor have to be over it in order to show up?
I don't think it would be good practice just to change the cursor when it's not in your UI. You wouldn't want another program messing with the cursor in your UI. If you just want to show that your application is running, have you thought of using a tray app. These are relatively simple to create.
Here's an example I just googled:
http://alanbondo.wordpress.com/2008/06/22/creating-a-system-tray-app-with-c/
You can also show speech bubble messages as your run progresses etc, if you want to let the user know things are happening.
I do not need a main form
Yes, you do. Any UI interaction needs a form, sorry.
way for me to fake the existence of a WinForm (so that it exists but is not visible)?
How is that faking?
Make a form, make it invisible (transaprent - check all the properties on the form class and you will find it) and finished ;) Standard approach. Also tell it not to show up in the forms collection in the bottom of the screen and minimize it and you are finished. nothing fake here.
TomTom++
Are you just wanting to change the current cursor?
Try this
http://www.csharp-examples.net/hourglass-wait-cursor/
I wanted to create a program that would allow me to open instances of a already exsiting program (i just have the exe) as windows inside (i belive its called mdi)
Is that something i could do? can anyone point me to an example?
Thanks
Maybe this is the answer you are looking for here. It can be done...look in the sample on that link given.
Hope this helps,
Best regards,
Tom.
When Windows starts a program its parent is the Desktop Window.
If you could somehow manipulate that, it may work.
However, I doubt it is possible, as why would I want to allow you to run my application in your window? Especially MDI? Besides that - running in a child window isn't quite the same as running in the "main" window.
Having said that there is an application out there (can't think of it's name OH) that does place individual applications in tabs. Pretty nifty if you're not on Windows 7. The folks over at the Business of Software forum might be able to help you find it.
Well, after starting the app and storing its PID, you could start monitor the windows that get created, either thru a CBTHook or by just using a timer and the GetWindows to find when a top level window gets created by the PID in question.
Then you can use SetParent to make that window a child to your MDIChild (I doubt you can make it your MDIChild directly).
That should get you going. What you'll run into after that I really don't know. I guess you must correlate any movement of either your app or the external app so that thir windows appears to be stuck together...
Maybo you could strip away the caption from the external app (Get/SetWindowsLong). That could make it look better...