Thread: A Form is opened

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    385

    A Form is opened

    When open Form2 from Form1 a messageBox should appear but this code is not working.
    Any ideas to what I could be doing wrong.

    Code:
    private: System::Void Form1::Form2::OnShow(System::Object^ sender, System::EventArgs^ e)
    { 
    
         MessageBox:: Show("This window just opened");
    
    }
    Last edited by Coding; 02-16-2008 at 01:36 PM.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    385
    If you put this code like this under void InitializeComponent(void) in Form2, close the application and open the whole application from the beginning. The messageBox will appear before Form1 wich is the first Form that appears when the application opens but when open Form2 the MessageBox doesn´t appear so it seems that all forms loads into memory one time and something else is needed here to do.


    Code:
    void InitializeComponent(void)
    {
    MessageBox::Show(this, "Window Reloaded");
    }

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    385
    Found a solution. This is the way to do it.

    Code:
    Form2(void)
    {
    InitializeComponent();
    }     
    			
    protected: 
      virtual void OnActivated( EventArgs^ e ) override
    {
        MessageBox::Show("This window just opened");  
    }
    Last edited by Coding; 02-18-2008 at 11:01 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reopening a form ?
    By Aga^^ in forum C# Programming
    Replies: 1
    Last Post: 02-11-2009, 09:28 AM
  2. Calling datas from another form?
    By Aga^^ in forum C# Programming
    Replies: 2
    Last Post: 02-06-2009, 02:17 AM
  3. Accessing main form from functions in other classes
    By pj_martins in forum C++ Programming
    Replies: 1
    Last Post: 11-05-2004, 09:27 AM
  4. My UserControls dissapear off my form
    By zMan in forum C# Programming
    Replies: 2
    Last Post: 09-15-2004, 08:55 AM
  5. Making an MFC form to suit
    By TJJ in forum Windows Programming
    Replies: 1
    Last Post: 04-17-2004, 11:20 AM