Empty child window...

This is a discussion on Empty child window... within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to implement a child window so I can put buttons and such in it, though things aren't going ...

  1. #1
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204

    Thumbs up Empty child window...

    I'm trying to implement a child window so I can put buttons and such in it, though things aren't going to plan. This is what I've got:

    Code:
    hChild = CreateWindowEx( NULL, "", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hMainWindow, (HMENU)ID_CHILD, GetInstance(), NULL );
    The problem is, hChild is always 0 (because it failed). I'm guessing the problem is that I don't have a WNDCLASSEX in there, but I want it to be empty. So what's wrong? Or am I going about this the complete wrong way?

    Cheers.

    EDIT: Sorry, I should've explained the situation more. What I'm trying to do is implement pages in my Tab Controls. I've got the tabs appearing and running fine, but I'm thinking I will add a child window for each page. When the user clicks on a tab, I'll use ShowWindow() to hide the old child window and display the new one. I've figured this would be a pretty good way of doing it (or is it?). So, more or less, how do you implement a child window into a tab, so that I can put in my other controls on the page?
    Last edited by yaya; 10-29-2009 at 04:45 PM.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Try the DialogBox instead, just declare a template for the window (not necessary the inside controls) and a procedure for that window. Something like that, first setup the template on the resource file:

    Code:
    MYSAMPLEWINDOW DIALOG DISCARDABLE  0, 0, 100, 100
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION NOMAPP
    FONT 8, "MS Sans Serif"
    BEGIN
    END
    Notice that 'MYSAMPLEWINDOW' will be the window identifyer, so define it on your definitions file:

    Code:
    #define MYSAMPLEWINDOW 1000
    Declare a procedure for that window:

    Code:
    BOOL CALLBACK MySampleWindowProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
    switch(msg)
        {
        default: return 0;
        }
    return 1;
    }
    In the window's procedure you'll have to check the WM_ messages to respond to the window's events. Finally create the dialog:

    Code:
    DialogBox(GetModuleHandle(0),MAKEINTRESOURCE(MYSAMPLEWINDOW),hwnd,MySampleWindowProc);
    Take a look to the win32 prog reference, or in the msdn to see more about that function, and check oput also the function DialogBoxParam.

    Still another way to do it is creating your own window class, you can find more about that on catch22 (I'm not sure the section's name, but was something like custom controls from scratch).

    Hope that helps
    Niara

  3. #3
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204
    Sorry, I should've explained the situation more. What I'm trying to do is implement pages in my Tab Controls. I've got the tabs appearing and running fine, but I'm thinking I will add a child window for each page. When the user clicks on a tab, I'll use ShowWindow() to hide the old child window and display the new one. I've figured this would be a pretty good way of doing it (or is it?). So, more or less, how do you implement a child window into a tab, so that I can put in my other controls on the page?

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    That is the way I do it.

    I 'draw' the dialog in the IDEs resource edtior, [the bit you have missed]
    create all the child dilalogs when the TAB is created
    and hide/show the appropriate one on TAB selection change.
    "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

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Ok, I was thinking you needed a popup. As novacain said, that's also the way I do it.

    Niara

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  2. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  3. Child window inside child window
    By Magos in forum Windows Programming
    Replies: 13
    Last Post: 04-20-2004, 06:51 AM
  4. Child window with active (highlighted) title bar: Possible?
    By JasonD in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2003, 06:43 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

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