C
CSharp-Jay
I have a bit of a weird problem, I am currently a student learning
advanced C#. Today I decided to make a little program that tests my
knowledge while allowing me to learn new things and I hit a little
hiccup. Basically my initial form is named frmBackground. I've
programmed it to full truescreen mode. As soon as it is loaded, it
loads a child form called frmMain which stays on top of
frmBackground. The user from there can make a selection via a button
and when that selection is made, frmMain needs to close and the new
form which the user selected needs to pop up. The problem is that I
can get the new form to pop up but frmMain won't go away. If I close
the new form, THEN it goes away and I am left with the full screen
black background. I get the feeling that frmMain is still visible
although not loaded or something and it is hanging out there
completely dependent on the new form closing. Can somebody help with
this? I think I just need to know how a use can click a button in
frmMain, make frmMain unload itself AND load a new form. Here is the
code snip for frmBackground:
public partial class frmBackground : Form
{
frmMain main = new frmMain();
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string
windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
public frmBackground()
{
InitializeComponent();
}
private void frmBackground_Load(object sender, EventArgs e)
{
int hwnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hwnd, SW_HIDE);
main.Show();
}
advanced C#. Today I decided to make a little program that tests my
knowledge while allowing me to learn new things and I hit a little
hiccup. Basically my initial form is named frmBackground. I've
programmed it to full truescreen mode. As soon as it is loaded, it
loads a child form called frmMain which stays on top of
frmBackground. The user from there can make a selection via a button
and when that selection is made, frmMain needs to close and the new
form which the user selected needs to pop up. The problem is that I
can get the new form to pop up but frmMain won't go away. If I close
the new form, THEN it goes away and I am left with the full screen
black background. I get the feeling that frmMain is still visible
although not loaded or something and it is hanging out there
completely dependent on the new form closing. Can somebody help with
this? I think I just need to know how a use can click a button in
frmMain, make frmMain unload itself AND load a new form. Here is the
code snip for frmBackground:
public partial class frmBackground : Form
{
frmMain main = new frmMain();
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string
windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
public frmBackground()
{
InitializeComponent();
}
private void frmBackground_Load(object sender, EventArgs e)
{
int hwnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hwnd, SW_HIDE);
main.Show();
}