Simple Question But Im a Newbie : How do I open a new window And close the old one?

This is a discussion on Simple Question But Im a Newbie : How do I open a new window And close the old one? within the Windows Programming forums, part of the Platform Specific Boards category; Making a chat server. In Visual C++, how do I close an old window and open up a new one. ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    33

    Question Simple Question But Im a Newbie : How do I open a new window And close the old one?

    Making a chat server. In Visual C++, how do I close an old window and open up a new one. (rather a new dialog). Whats the command?
    "Who ya gonna call?"

    AWAX

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Well, you don't *just* close and open windows with one command. First you have to set the fields of a WNDCLASS, then register the class. CreateWindow() will create the window, ShowWindow will show the window, and UpdateWindow will cause a WM_PAINT message to bypass the quaeu to paint to the client area.

    --Garfield
    1978 Silver Anniversary Corvette

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    33
    I inserted a resource into my workspace. A dialog window and made a Cdialog child class with it in the class wizard.
    Did this create the window? Or is there something else I need to do. Like add a member variable of the child class type to the Main Dialog class to create the window?
    I tried DoModal. It didnt work, and I couldn't figure out ShowWindow. Is there anyway you could post a small example or send me a link? - Zedd
    "Who ya gonna call?"

    AWAX

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    A dialog window and made a Cdialog child class with it in the class wizard.
    Did this create the window?
    No, you have to create an instance of this class, and then call DoModal(). If you're not sure, look how the default wizard creates the code that will display the about box.
    zen

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    33
    GRRRRRRRRRRRR

    I tried it repeatedly. And try doing the same thing they did in the About Dialog. It keeps telling me my CDialog Child Class made for that Dialog, CCHAT is an undeclared identifier when I edit the code on the button to connect.
    Im getting really frustrated. I made a member function ( I guess it turned out to be a constructor) and I still can't get it to work. What gives? - Zedd
    "Who ya gonna call?"

    AWAX

  6. #6
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    When you create a new class with the class wizard, it creates two new files - the .h and .cpp files. You'll have to include the header file for your new dialog class in the file that your creating an instance in. So make sure you've got "CHAT.h" included.
    zen

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Instaed of closing the windows/dialogs just hide them with ShowWindow(hWnd,SW_HIDE) [SW_HIDE=0]

    When you need them call tehm again with SW_SHOW [SW_SHOW=1].
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #8
    Sayeh
    Guest
    This is one of the areas I find the standard API cleaner than MFC-- no class junk.

    you use CreateWindow() and a handle to a window structure. You can dispose of the window easily by passing the handle of the created window to DisposeWindow(). You can hide/show the window easily with ShowWind().

    Fast, easy to manage, effecient.

  9. #9
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    DisposeWindow()?
    I have MSDevStudio 97/5, no DisposeWindow() in help, do you mean DestroyWindow()? Or has it been added to v6?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 11:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 05:10 AM

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