Child window outside of parent

This is a discussion on Child window outside of parent within the Windows Programming forums, part of the Platform Specific Boards category; I want to make my own little window, but how do I get it to be moveable outside of it's ...

  1. #1
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293

    Child window outside of parent

    I want to make my own little window, but how do I get it to be moveable outside of it's parent?

    I've tried the WS_POPUP style but it doesn't show up after that! Am I supposed to handle something in the window proc?
    Last edited by Mithoric; 03-07-2004 at 05:39 AM.

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    I want to make my own little window
    How are you creating the window? Using CreateWindowEx()?

    If you're talking about creating an owned window, register and create a new window. Set the owner window in CreateWindowEx().

    Alternatively, use CreateDialog() and a dialog resource.

  3. #3
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    It is first registered using registerclassex and then I handle the painting in it's proc. I am just using CreateWindow() to make it. Should I be using CreateWindowEx()? I don't see how unless I am setting an extended style, which at this point in time I don't think I am in need of doing.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Are you using the WS_CHILD and WS_POPUP?

    If so don't, they can't be combined.

    Don't make the new window a child.
    "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
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Nope, only WS_VISIBLE|WS_POPUP .. I had read in MSDN that ```````

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    does it get to the new windows WM_CREATE? (ie put a break point there)


    Pure speculation without code...

    >>but how do I get it to be moveable outside of it's parent?

    Child windows are restricted to the parents client area.
    MSDN: "A child window has the WS_CHILD style and is confined to the client area of its parent window."

    Also try moving it to the front of the z-order with SetWindowPos() HWND_TOPMOST, could be under another window?

    I have had problems with winclasses not registering properly. Sometimes spaces in the winclass name cause problems.
    "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

  7. #7
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Well I gather it gets to the WM_CREATE because you can see it..

    Here is how I register it -
    Code:
    bool RegisterCLPSWnd ( HINSTANCE hInstance ) {
        
        WNDCLASSEX wnclex;
        wnclex.cbSize = sizeof ( WNDCLASSEX );
        wnclex.style = CS_DBLCLKS;
        wnclex.lpfnWndProc = clpswndproc;
        wnclex.cbClsExtra = 0;
        wnclex.cbWndExtra = sizeof( CLPSWNDSTRUCT*);
        wnclex.hInstance = hInstance;
        wnclex.hIcon = NULL;
        wnclex.hCursor = LoadCursor ( NULL, IDC_ARROW );
        wnclex.hbrBackground = GetSysColorBrush ( COLOR_3DFACE );
        wnclex.lpszMenuName = NULL;
        wnclex.lpszClassName = "mith32_clpswnd";
        wnclex.hIconSm = NULL;
        if ( !RegisterClassEx ( &wnclex ) ) {
            MessageBox ( NULL, "Unable to register class 'mith32_clpswnd'", "Error!", MB_ICONERROR );
            return false;
        }
        return true;
    }
    And this is the window proc--
    Code:
    LRESULT CALLBACK clpswndproc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
        
        CLPSWNDSTRUCT *cpw = (CLPSWNDSTRUCT*)GetWindowLong( hwnd, 0 );
        switch ( msg ) {
            
            case WM_NCCREATE: {
             CLPSWNDSTRUCT* cpw = (CLPSWNDSTRUCT*)malloc(sizeof(CLPSWNDSTRUCT));
             if( cpw == NULL ) {
               MessageBox( NULL, "wm_nc.clpswndproc Failed!", "Error", MB_ICONERROR );
             }
             cpw->docked=true;
             SetWindowLong( hwnd, 0, (LONG)cpw );
             return true;
            }
            case WM_LBUTTONDOWN: {
              
              //TODO.
              return 0;
            }
            case WM_PAINT: {
             
             PAINTSTRUCT ps;
             BeginPaint( hwnd, &ps );
              DrawCLPSWnd( hwnd, (CLPSWNDSTRUCT*)GetWindowLong( hwnd,0) );
             EndPaint( hwnd, &ps );
             return 0;
            }
            
        }
        
        return DefWindowProc( hwnd, msg, wParam, lParam );
    }
    If I specify WS_VISIBLE|WS_POPUP it just doesn't get to the WM_CREATE ( I think this is what you were getting at )..

  8. #8
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Could I see what your CreateWindowEx() code looks like for your child/owned window?

  9. #9
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Sure -- It's done through a member of the class cCtrlBase.

    How I init it --
    Code:
    abtwnd.InitEx ( NULL, "mith32_clpswnd", "About GUI Magic.", 100,100, 350, 125,
                        -1,WS_VISIBLE| WS_OVERLAPPED | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, hwnd );
    Member part --
    Code:
    this->hSelf = CreateWindowEx ( this->dwStyleEx, this->lpClass, this->lpText, this->dwStyle, this->x, this->y,
            this->cx, this->cy, this->hPrnt, (HMENU)this->id, GetModuleHandle(NULL), NULL );
    Last edited by Mithoric; 03-10-2004 at 05:17 AM.

  10. #10
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Try,

    m_Dlg.Create(MAKEINTRESOURCE(IDD_DIALOG),this);


    or

    Don't use WS_CLIPSIBLINGS (as have to have the WS_CHILD as well)

    Don't cast the menu to an int ID unless using the child style ( (HMENU)this->id )
    Last edited by novacain; 03-10-2004 at 09:45 PM.
    "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

  11. #11
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    K, I'll have a little fiddle and mod my member to allow for that.

  12. #12
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Yay! I modified my class member init function to allow for using no id and it works nicely.

    Thanks a bunch!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  2. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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