Sign in to follow this  

[Win32] Closing Child window causes Parent window to close?

This topic is 2830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i prevent that? (i want to be able to close the child window w/o closing its parent) I'm just using the code you get when creating a new Win32 app in Visual Studio plus this:
 c_hWnd = CreateWindowW(szWindowClass, L"Child", WS_CHILD | WS_OVERLAPPEDWINDOW,
     400, 100, 200, 300, hWnd, NULL, hInstance, NULL);

   ShowWindow(c_hWnd, nCmdShow);
   UpdateWindow(c_hWnd);

Share this post


Link to post
Share on other sites
If you have two different windows, they probably shouldn't have the same WndProc. It is likely that your child window's either explicit or default handling of WM_DESTROY is calling PostQuitMessage(0).

You should create a WndProc for your child window that is designed for a child rather than application window. If you post the WndProc here, that would probably get to the bottom of things.

I feel obliged to suggest that Windows API is a rubbish way to write GUI-based applications compared to C# and WinForms, but bleh.

Share this post


Link to post
Share on other sites
So i will have to create and register a new Window Class for the Child Window? (to pass the new WndProc)

I really don't use Win32 much, don't see how it could be useful for gaming really..

I'm just asking about child windows so as to create one that pops up when a user launches my game to specify some options. Like if he wants to run the game in fullscreen, what resolution to use, etc..

Share this post


Link to post
Share on other sites
Yeah, normally if you have a new type of window, you'd register the new window class. You can subclass the window and set a new window procedure using SetWindowLongPtr, but this sounds more like a new window class case than a subclass case to me.

Personally, I use a dialog as a first-run window, created in the RC file for the project, but if I was creating the first-run window in code, I'd certainly create a new window class and have it's own WndProc.

Having your existing codebase in unmanaged C++ and wanting a first-run dialog is a good excuse (IMHO) for using Windows API for this sort of thing. If you are using Express VS, you might like to look into ResEdit for creating dialogs without the pain.

Share this post


Link to post
Share on other sites
Well i've been reading this [long] article on Resource Files.. Sounds very confusing really. But i think by the time i'm done with it i'll have a good grasp on the subject.. If not, i hope you're around to answer ;)

Share this post


Link to post
Share on other sites

This topic is 2830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this