Splash screen moves up before closing
Posted
by rturney
on Stack Overflow
See other posts from Stack Overflow
or by rturney
Published on 2010-06-16T13:46:29Z
Indexed on
2010/06/16
13:52 UTC
Read the original article
Hit count: 321
c#
|splashscreen
In C# I am having a problem with the splash screen. When it is time to close and the main Form1 appears, it moves over to the upper right corner of Form1. It then disappears. I have never had this occur before and have just about run out of ideas to fix it. I want the splash screen to disappear in the center screen and not move over to the upper corner of the opening Form1. Here is the code:
public Form1()
{
Splash mySplash = new Splash();
mySplash.TotalValue = 7; //or however many steps you must complete
mySplash.Show();
mySplash.Update();
InitializeComponent();
//--<begin>--------------
this.Hide();
this.WindowState = FormWindowState.Normal;
mySplash.Progress++;
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
printBOM.PrintPage += new PrintPageEventHandler(printBOM_PrintPage);
printList.PrintPage += new PrintPageEventHandler(printList_PrintPage);
mySplash.Progress++;
// using old Kodak Imaging OCX !
axImgEdit1.Image = "\\\\Netstore\\eng_share\\EView\\BOB-eView9.tif";
axImgEdit1.DisplayScaleAlgorithm = ImgeditLibCtl.DisplayScaleConstants.wiScaleOptimize;
axImgEdit1.FitTo(0);
axImgEdit1.Display();
mySplash.Progress++;
//~~~~~~~~~~~~~~~~~~~~Getting printer info~~~~~~~~~~~~~~~~~~~~~~~~~
List<Win32_Printer> printerList = Win32_Printer.GetList();
int i = 0;
foreach (Win32_Printer printer in printerList)
{
prnName = printer.Name;
prnPort = printer.PortName;
prnDriver = printer.DriverName;
if (i == 0)
{
prnNameString = prnName;
prnDriverString = prnDriver;
prnPortString = prnPort;
}
else
{
prnNameString += "," + prnName;
prnDriverString += "," + prnDriver;
prnPortString += "," + prnPort;
}
i++;
}
mySplash.Progress++;
EViewMethods.defaultPrn[0] = Settings.Default.DefaultPrinter; //defaultPrn[] is string array holding the default printer name, driver and port
EViewMethods.defaultPrn[1] = Settings.Default.DefaultPrinterDriver;
EViewMethods.defaultPrn[2] = Settings.Default.DefaultPrinterPort;
//making this printer the system default printer
object printerName = Settings.Default.DefaultPrinter;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject currentObject in collection)
{
if (currentObject["name"].ToString() == printerName.ToString())
{
currentObject.InvokeMethod("SetDefaultPrinter", new object[] { printerName });
}
}
mySplash.Progress++;
EViewMethods.reCenterEVafterDwgClose = Settings.Default.ReCenterEVafterDwgClose;
if (Settings.Default.ReCenterEVafterDwgClose == true)
recenterEViewAfterDrawingViewerClosesToolStripMenuItem.Checked = true;
else
recenterEViewAfterDrawingViewerClosesToolStripMenuItem.Checked = false;
//-------------------------------------------------------
EViewMethods.screenBehavior = Settings.Default.ViewStyle;
normalToolStripMenuItem.Checked = false;
clearViewToolStripMenuItem.Checked = false;
clearviewDULevLRToolStripMenuItem.Checked = false;
clearviewdULevLLToolStripMenuItem.Checked = false;
clearviewdURevULToolStripMenuItem.Checked = false;
clearviewdURevLLToolStripMenuItem.Checked = false;
clearviewdURevLRToolStripMenuItem.Checked = false;
smallScreenToolStripMenuItem.Checked = false;
//Form1.ActiveForm.SetDesktopLocation(588, 312); //all screen behavior mode will begin centered on the screen
EViewMethods.eviewUserPrefLocation = Settings.Default.FormEviewLocation;
//-------------------------------------------------------
EViewMethods.syncListToDwgNum = Settings.Default.SyncListDwgNum;
if (EViewMethods.syncListToDwgNum == true)
synchronizeListToActiveDwgToolStripMenuItem.Checked = true;
else
synchronizeListToActiveDwgToolStripMenuItem.Checked = false;
toolStripStatusLabel1.Text = "";
toolStripStatusLabel2.Text = Settings.Default.ViewStyle;
toolStripStatusLabel3.Text = Settings.Default.DefaultPrinter;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assembly asm = Assembly.GetExecutingAssembly();
AssemblyName asmName = asm.GetName();
EViewMethods.eviewVersion = asmName.Version.ToString();
radioPartInfo.Checked = true;
disableAllSearch();
EViewMethods.userName = Environment.UserName;
EViewMethods.openConnection();
mySplash.Progress++;
EViewMethods.loadFavorites(listFavorites);
mySplash.Close();
mySplash.Dispose();
this.Show();
this.ActiveControl = comboEntry;
}
© Stack Overflow or respective owner