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?
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 06:39 AM.
How are you creating the window? Using CreateWindowEx()?I want to make my own little window
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.
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.
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
Nope, only WS_VISIBLE|WS_POPUP .. I had read in MSDN that ```````
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
Well I gather it gets to the WM_CREATE because you can see it..
Here is how I register it -
And this is the window proc--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; }
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 )..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 ); }
Could I see what your CreateWindowEx() code looks like for your child/owned window?
Sure -- It's done through a member of the class cCtrlBase.
How I init it --
Member part --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 );
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 06:17 AM.
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 10: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
K, I'll have a little fiddle and mod my member to allow for that.
Yay! I modified my class member init function to allow for using no id and it works nicely.
Thanks a bunch!