Pop-up screen displayed in the middle of the application

I have a list of report names displayed as a tree hierarchy in a ReportViewer control. When the user clicks on the name of the report, the input form is loaded, the user enters some values ​​and clicks OK. At this point, the Splash screen should load while the backend process is taking place (connecting to the database, retrieving values, etc.). After the report is loaded in the Reportviewer editor, the splash screen should be closed.

While I can display the splash screen, but it is stuck at this point, the actual report does not load, and the splash screen remains forever.

Is it possible to use splashscreen in the middle of the application, and not when the application starts? If so, how do I continue to download the report?

static class Program { [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SnapPlusReports()); //new SplashScreenApp().Run(args); } } public class SplashScreenApp : WindowsFormsApplicationBase { private static SplashScreenApp _application; public static void Run(Form form) { _application = new SplashScreenApp { MainForm = form }; _application.Run(Environment.GetCommandLineArgs()); } protected override void OnCreateSplashScreen() { this.SplashScreen = new ShowProgress(); base.OnCreateSplashScreen(); } } 
+4
source share
2 answers

I have done this before, creating a new form at runtime dynamically with code. Make sure you select all the options, especially FormBorderStyle, to no one, or something like that, so that the user cannot close it. Then just manipulate the shortcuts that appear on this form, and finally close them as soon as your process is complete. This way you don't have to worry about streaming usage, and a good side effect is that the original form will not be available.

For example, I have a form that appears at runtime (if I don't change anything, but the idea is:

 AboutForm aboutForm = new AboutForm(); aboutForm.StartPosition = FormStartPosition.CenterParent; Label lblAbout = new Label(); Version applicationVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; lblAbout.Text = applicationVersion.ToString(); lblAbout.Location = new Point(145,104); aboutForm.Controls.Add(lblAbout); aboutForm.ShowDialog(); 

Shows the version number of the current software, etc. There are other labels that already exist on the form (I first rendered it and then called the instance).

Hope this helps!

0
source

... Catch other instances and gracefully exit if you need only one copy of your application in memory at a specific time

 static void Main() { Application.EnableVisualStyles(); bool exclusive; System.Threading.Mutex appMutex = new System.Threading.Mutex(true, "MY_APP", out exclusive); if (!exclusive) { MessageBox.Show("Another instance of xxxx xxxBuilder is already running.","MY_APP", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); return; } Application.SetCompatibleTextRenderingDefault(false); xxxWindowsApplication.InitializeApplication(); Application.Run(new frmMenuBuilderMain()); GC.KeepAlive(appMutex); } 

In the main form load, you can do something like:

 private void frmMenuBuilderMain_Load(object sender, EventArgs e) { //Show Splash with timeout Here-- if(!SystemLogin.PerformLogin()) { this.Close(); return; } tmrLoad.Enabled = true; 

}

0
source

All Articles