A Form is opened

This is a discussion on A Form is opened within the Windows Programming forums, part of the Platform Specific Boards category; When open Form2 from Form1 a messageBox should appear but this code is not working. Any ideas to what I ...

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

    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
    383
    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
    383
    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, 09:55 AM
  5. Making an MFC form to suit
    By TJJ in forum Windows Programming
    Replies: 1
    Last Post: 04-17-2004, 12:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21