CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2006
    Posts
    16

    Unhappy I can not call the forms declared in Form1.h

    Hi friends, i'm a new programmer. During an application, i want to call a form by clicking somewhere. For example, when i click Help/About Menu, i want the About.h form to start.
    To do this, i declare it like that;

    #include "About.h"
    .
    .
    .
    private: About^ aboutBox;
    .
    .
    .
    .
    .
    aboutBox = gcnew About;
    --------------------------------
    But there are many errors when i debug,
    such as;
    error C3845: 'MyMessenger::Form1::aboutBox': only static data members can be initialized inside a ref class or value type

    please help me about this problem. Do you suggest any other methods?

  2. #2
    Join Date
    Dec 2006
    Posts
    16

    Re: I can not call the forms declared in Form1.h

    In the MSND library, i saw such an example to display user defined dialogs;

    {

    Form ^ f = gcnew Form();
    f->ShowDialog();
    }

    And i changed this code to display my About.h form dialog such as;

    {

    Form ^ About = gcnew Form();
    About->ShowDialog();
    }

    But, i still see the same empty dialog instead of my About.h form. So how can i display this dialog when i click About menu ?

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: I can not call the forms declared in Form1.h

    That code isn't Visual C++. You may do better in an appropriate forum.

  4. #4
    Join Date
    Dec 2006
    Posts
    16

    Re: I can not call the forms declared in Form1.h

    Quote Originally Posted by GCDEF
    That code isn't Visual C++. You may do better in an appropriate forum.
    I found the codes in my second message from MSDN VC++ 2005 samples, and there may be some differences from 2003 version, so i don't think Microsoft is doing such a great mistake !!!
    Last edited by Noreturn; December 23rd, 2006 at 07:22 PM.

  5. #5
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: I can not call the forms declared in Form1.h

    Quote Originally Posted by GCDEF
    That code isn't Visual C++. You may do better in an appropriate forum.
    Yes, it is - but it's managed C++, so it should be moved to the Managed C++ and C++/CLI forum.

    @Noreturn: The code you posted is not enough to analyze your problem. Please post more complete code - and use code tags when doing so.

  6. #6
    Join Date
    Dec 2006
    Posts
    16

    Re: I can not call the forms declared in Form1.h

    Quote Originally Posted by gstercken
    Yes, it is - but it's managed C++, so it should be moved to the Managed C++ and C++/CLI forum.

    @Noreturn: The code you posted is not enough to analyze your problem. Please post more complete code - and use code tags when doing so.

    Thanks for your suggestion...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured