CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: Close form?

  1. #1
    Join Date
    Feb 2009
    Posts
    201

    Close form?

    Hello, all!

    I have this request or a question.

    I ues Microsoft Virsual Studio 2008: Exprees editon. With C++.

    I created a form called Form1.

    And I created another form called form2.

    But when I open up form2, my Form1 is still open. How can I close that one? Or hide it?

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Close form?

    This question gets asked a lot... and I always answer the same thing.

    What are you trying to do ? Apart from splash screens no application in Windows behaves the way you are describing - so that does suggest that your UI design is wrong.

    So post what you're trying to do and I'll see if I can't take you further...

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Feb 2009
    Posts
    201

    Re: Close form?

    I'm trying to create a Windows Form Application.

    I created two forms. When I built the program, I see both forms. However I should only see Form1. Untill my button is clicked, then Form1 should be hided and form2 should show up.

  4. #4
    Join Date
    Apr 2009
    Location
    Netherlands
    Posts
    91

    Re: Close form?

    Quote Originally Posted by realchamp View Post
    I'm trying to create a Windows Form Application.

    I created two forms. When I built the program, I see both forms. However I should only see Form1. Untill my button is clicked, then Form1 should be hided and form2 should show up.
    I don't think you get what darwin means. He doesn't understand why you want that behaviour from your application. What is the point of this setup? Shouldn't you just be hiding and unhiding controls on 1 form instead?

  5. #5
    Join Date
    Feb 2009
    Posts
    201

    Re: Close form?

    Derp.
    Last edited by realchamp; April 5th, 2012 at 11:53 AM.

  6. #6
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Close form?

    You want a wizard.

    (1) Do your UI work in C# and not C++/CLI. Forms in C++/CLI is painful.
    (2) See here for a wizard component.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  7. #7
    Join Date
    Feb 2009
    Posts
    201

    Re: Close form?

    Yeah I've been told to use C#.

    But I don't want to teach C# now when I just learned C++.

    Or do you have a free online guide for C#?
    I'd like to have that one!

    And thanks!

  8. #8
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Close form?

    Learning C++/CLI does not teach you C++. Do you know what an std::vector is ?

    If you want to learn .NET, then switch to using C#.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  9. #9
    Join Date
    Apr 2009
    Location
    Netherlands
    Posts
    91

    Re: Close form?

    Syntax wise c# isn't that different from c++. I find c# to be very intuitive as an OOP programmer. Picked up on c# quite easily.

  10. #10
    Join Date
    Feb 2009
    Posts
    201

    Re: Close form?

    I know C# almost has the same syntax. However the commands are different.

    Well I will have a look at C#!

    Thanks guys!

  11. #11
    Join Date
    Feb 2007
    Posts
    43

    Re: Close form?

    @Darwen:

    (a diversion, please forgive me)

    C++ seems fine to me. The beauty of .NET ( in my super-limited experience ) is that it doesn't seem to matter what language I'm using. Can you explain why C# is so much better for people working with .NET / forms?

    Not a crit, by the way, I really want to know if I should be switching to C#.

  12. #12
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Close form?

    C++ seems fine to me. The beauty of .NET ( in my super-limited experience ) is that it doesn't seem to matter what language I'm using.
    Absolutely. Which is why I use C#. Just from a language point of view I find it much quicker to develop in than C++/CLI.

    1. Intellisense works !
    2. No need to seperate out .h and .cpp. No need to write method definitions twice (and make sure they match up grrr).
    3. Having '.' as a namespace separator : easier to type than 2 colons.
    4. No #includes... oh the joy !
    5. Lots and lots more...

    Can you explain why C# is so much better for people working with .NET / forms?
    Compare the code generated by the designer in C# (quite nice) to the code generated by the designer in C++/CLI (not nice at all).

    Also it's very easy to break the designer in C++/CLI. It's still possible to break the designer in C#, but it's a lot more stable from my experience.

    Of course, these are just my own opinions.

    Darwen.
    Last edited by darwen; April 29th, 2009 at 04:23 PM.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

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