   Child window problem, help wanted!
  Hey there,I have a problem with my child window, im trying to add WS_CAPTION to it so that i can move it around inside the main window but the text input and output stops working (like static-ish... can´t touch it) so if anyone here knows what im doing wrong, please help :).So to the code part, this is how im doing this:I create the main window in a seperate function (it´s actually a GL window btw) like normal:// Create the windowglWin.hWnd = CreateWindowEx(0, WINDOW_CLASS, WINDOW_NAME, WINDOW_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, winMain.hInstance, NULL);if (!glWin.hWnd){UnregisterClass(WINDOW_CLASS, winMain.hInstance);Com_Printf("...could not create window\n");return false;}// Initialize console child windowCon_Init();I call the child console window just right after the main window is created and then in the console function i do this:// Create the windowconWin.hWnd = CreateWindowEx(0, "EDIT", NULL, WS_CHILD | WS_VISIBLE, 5, 5, 540, 450, glWin.hWnd, NULL, winMain.hInstance, NULL);if (!conWin.hWnd)MessageBox(NULL, NULL, "Could not create console window", MB_OK | MB_ICONERROR | MB_TASKMODAL);// Create the controlsconWin.hWndOutput = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY, 5, 40, 530, 350, conWin.hWnd, NULL, winMain.hInstance, NULL);conWin.hWndInput = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL, 5, 395, 530, 20, conWin.hWnd, NULL, winMain.hInstance, NULL);I create a main child window and then adding two more child windows inside it, an output and input but whenever i add "WS_CAPTION" to the main child window, it freezes :s. My goal is to make a half-life 2-ish command console :P.Note: If there is anything i missed to include here like WinMain, WinProc or something, just ask and i´ll show you.- Thanks   
  Having childs with captions is ... weird, but it should work.Please show the main window proc and the message pump.   ;  Not sure what exactly is going on with the code you've shown. However, if I were you, if you want to have child windows that act like overlapped windows except within the client area of a parent, I'd set it up as an MDI application. MDI stands for multiple document interface (I think) ... here's some sample code. MDI apps are about the only time anyone ever does what you're doing in Win32 so probably going to be easiest to get it working this way.   ;  Hmm im not exacly sure how im going to reach my goal but the idea is to have a command console inside the main window similar to the link below which you can move around, type in and read output text.>> Please show the main window proc and the message pump.- Yeah sure, im just redoing the thing (damn bug! lol) going to put it up asap.>> @ jwezorek- The way i do is i create a main window class/handle as everyone does, then i create a main child window handle, call the main window handle in the child window "CreateWindowEx();" func, create two more child windows, call the child main window handle in the two child windows "CreateWindowEx();" func.Sounds kinda confusing but i hope you get the idea ;P.My reference console idea:http://download.gna.org/algoscore/Help/console.pnghttp://media.moddb.com/images/mods/1/7/6729/44506.jpg << Half-life 2[Edited by - 0Buzzard on May 17, 2010 4:27:33 PM];  Is that actual code in your first post? and is conWin.hWnd supposed to be a console window that has two child edit boxes, one for input and one for output? Because the way it's written  conWin.hWnd is getting created as an edit box itself and then you're trying to give that edit box two child edit boxes. The console window should be a custom class.   ;Quote:Original post by jwezorekIs that actual code in your first post? and is conWin.hWnd supposed to be a console window that has two child edit boxes, one for input and one for output? Because the way it's written  conWin.hWnd is getting created as an edit box itself and then you're trying to give that edit box two child edit boxes. The console window should be a custom class.Yes, i didn´t know which class to use, if i should create a new one or use a system class so i just went with "EDIT" which was a mistake lol. So you are suggesting that i should make a new window class for the console?.   ;  Yeah, you should register a class with class name "MyConsoleClass" or whatever and create that as a child of your main window; it'll need a WndProc and so forth just like you had to do with your main window. I guess create the console window with style WS_CHILD | WS_CAPTION | WS_VISIBLE. I say "I guess" because I haven't tried creating child windows that you expect win32 to allow to be automatically moved around by the user but clipped/owned by the parent -- at least I haven't tried it for long a time. I think that that will work; anyway you could get it to work. But I really recommend looking at the MDI code project example that I posted above. That is close to doing what you want to do, and if you're a beginner, which you seem to be, it's easier to do things the standard way.   ;Quote:Original post by jwezorekYeah, you should register a class with class name "MyConsoleClass" or whatever and create that as a child of your main window; it'll need a WndProc and so forth just like you had to do with your main window. I guess create the console window with style WS_CHILD | WS_CAPTION | WS_VISIBLE. I say "I guess" because I haven't tried creating child windows that you expect win32 to allow to be automatically moved around by the user but clipped/owned by the parent -- at least I haven't tried it for long a time. I think that that will work; anyway you could get it to work. But I really recommend looking at the MDI code project example that I posted above. That is close to doing what you want to do, and if you're a beginner, which you seem to be, it's easier to do things the standard way.Okey, im going to try with that and see how it goes. I tried the MDI stuff but it seems too complicated atm, i have one solution that works but i want the console to be in it´s own window inside the main window. About creating a new class, should the hInstance still be the same one as the main window uses?. Oh and in the console WindowProc, is there any special message i should handle for the console window, like WM_CREATE or something? (i´ve seen people use that for child windows).For the main window style, it seems that i need WS_CLIPCHILDREN, is that necessary?. Because i cannot get it to work otherwise :s.Also, you should be able to close/open the console so i added WS_SYSMENU but when i click the X close icon, both the window and console closes for some reason. I guess it´s because they both use the same message loop.- This is how the console window looks atm:http://paste.ideaslabs.com/show/TJ0hqrXEQlBtw thanks for all your replys so far :).[Edited by - 0Buzzard on May 18, 2010 6:55:33 AM];Quote:Okey, im going to try with that and see how it goes. I tried the MDI stuff but it seems too complicated atm, Well, suit yourself -- I think that stuff is on top of the rest of the API anyway, so it shouldn't be necessary.Quote:About creating a new class, should the hInstance still be the same one as the main window uses?. yesQuote:Oh and in the console WindowProc, is there any special message i should handle for the console window, like WM_CREATE or something? (i´ve seen people use that for child windows).Nothing in particular. It's going to be the parent of two edit controls so it should handle the edit control notifications that you need to, if there are any.Quote:For the main window style, it seems that i need WS_CLIPCHILDREN, is that necessary?. Because i cannot get it to work otherwise :s.You should use WS_CLIPCHILDREN and WS_CLIPSIBLINGS when creating the main window.Quote:Also, you should be able to close/open the console so i added WS_SYSMENU but when i click the X close icon, both the window and console closes for some reason. Don't know. Would have to see your code.   ;  Okey so now im kinda back to my main problem. When i uncomment the WS_CAPTION, the window edit boxes freezes (input/output) but when i comment it i can select the output text and write in the input bar but then it´s static.I added three URL´s to the console, main window and WinMain/Proc files.I also added two download .exe files with WS_CAPTION disabled/enabled so that youcan see what i mean by "freezes"http://utilitybase.com/paste/31583 - Console Window Filehttp://utilitybase.com/paste/31584 - Main Window File (GL window)http://utilitybase.com/paste/31585 - WinMain and WindowProc Filehttp://www.speedyshare.com/files/22499072/Evolution.exe - Without WS_CAPTIONhttp://www.speedyshare.com/files/22499113/Evolution.exe - With WS_CAPTION[Edited by - 0Buzzard on May 18, 2010 9:42:46 AM]