Please note that I mean overlapping windows in a literal sense, not in the DWSTYLE sense listed within this very function.

I've been having this problem for quite a while now whereby I create a number of windows using the above function and have been having issues with the main, parent window not overlapping when brought into focus. Really I have three main objectives I wish to have work in unison yet at the moment, I seem to only be able to have one work at any given time.

1)For each of the created windows to be brought forward into focus whenever clicked, whether that be the first or twenty first created window.

2)For only a single program instance to appear on the taskbar in windows.

3)For each created window to share the same wndproc. E.g. if one window minimizes, as do all the rest.

I start off by creating all relevant usual parameters required for creating the window.

//Setup the window class itself.
	wcex.cbClsExtra = 0;				           //Remain at zero
	wcex.cbSize = sizeof(WNDCLASSEX);		                    //Byte size of the struct
	wcex.cbWndExtra = 0;					  //Remain at zero
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+2);	           //Window background colour value.
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);			  //Application cursor
	wcex.hIcon = 0;						  //Window icon
	wcex.hIconSm = 0;						  //Small window icon
	wcex.hInstance = newHandle.hInstance;			  //Window handle.
	wcex.lpfnWndProc = (WNDPROC)msgProc;				  //Window procedure.
	wcex.lpszClassName = "DirectX Class";			  //Window main name.
	wcex.lpszMenuName = NULL;			                    //Here to add a menu system. = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE | CS_DBLCLKS;	  //Class style.  See
	//Register the desired window class parameters to the system.

	//Setup the window style.

After having done this, I have the option to include this following code snippet.

//Set the first window created as the main window, if applicable.
	//HEREMARK - This stops the main parent window from ever being the front, main window in case of an overlap.  Why?
	HWND parentWindow = NULL;
	if((int)displayHandles.size() > 0)
		parentWindow =;

I then create the window as per usual:

//Creates the window with appropriate values.
	if(!(newHandle.wndHandle = CreateWindow("DirectX Class",	       //Must be the same as wcex.lpszClassName.
                                                 APPLICATION_NAME.c_str(),      //Window title bar name.
                                                 dwStyle,		       //Styles associated with the newly created window.
                                                 xPos,			       //X Position.
                                                 yPos,			       //Y Position.
                                                 xSize,     		       //Width.
                                                 ySize,		       //Height.
                                                 parentWindow,		       //Window parent.  Defaults to windows if unset.
                                                 NULL,			       //Menu handle.
                                                 newHandle.hInstance,	       //Handle to the window instance this will be associated with.
                                                 this)))	 	       //For client/child windows.  See

If I set the parent window as in the second code snippet, all of the windows get grouped as one program on the taskbar and each windows window message gets shared so tick off requirements 2 and 3. The main, parent window however, will refuse to be drawn on top of the other windows, no matter how I try to influence it (not the SetFocus function doesn't achieve this either).

If I simply set no parentWindow up, each window will happily overlap correctly so tick of requirement number one. Each window however then acts individually and is represented as a seperate program on the taskbar (closing down one will still close down all of the rest however).

I'm pretty sure I'm just missing something like a simple DWSTYLE input but I can't for the life of me figure out which one(s) to use.

Any pointers would be massively appreciated, thanks.

edit:Argh @ reformatting being different from preview and the actual post! :D

And after a long time trying to figure this out, shortly after posting here, I figured it out anyway.

Get rid of parent windowing altogether, use the CreateWindowEx function instead and add to the extended style, first parameter, WS_EX_TOOLWINDOW.

While the title bars size is now giving me issues, it still does the job correctly.

Even better, I've created a dummy HWND and given it the value SW_HIDE to give each window equal rights overlapping, the first window created sets windows as its parent for the taskbar icon, then all subsequent windows have the dummy as their parent to hide from the taskbar.

Job done!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.