Jump to content
  • Advertisement
Sign in to follow this  
sipickles

[win32 API/c++] Problems controlling z order of child windows

This topic is 4027 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

Hi, I am trying to layer videos over each other. Imagine I have one big video playing which fills the whole window, then am playing short small clips over the top. I am using the WMPSDK, and can get a video playing on top of another, based on the sample code WMPHost. The videos are all child windows of the application window, the root. I am creating instances of the CWMPHost class from the sample. My problem is I don't seem to be able to order the windows, top to bottom. Here are my attempts, all useless!
//HWND bg; // handle to background video/jpg
// HWND vid; // handle to clip I am trying to overlay

// ignore x and y stuff
SetWindowPos( vid, bg, x, y, w, h, 0 );

SetWindowPos( vid, HWND_TOPMOST, x, y, w, h, 0 );

SetWindowPos( vid, HWND_TOP, x, y, w, h, 0 );
SetWindowPos( bg, HWND_NOTOPMOST, x, y, w, h, 0 );

SetWindowPos( vid, HWND_TOP, x, y, w, h, 0 );
SetWindowPos( bg, HWND_BOTTOM, x, y, w, h, 0 );




I know my handles are good since this works:
// Show video
	SetWindowPos(vid, NULL, m_x, m_y, m_w, m_h, SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW );

// Hide video
	SetWindowPos(vid, NULL, m_x, m_y, m_w, m_h, SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER | SWP_HIDEWINDOW );



The ordering of layers seems to be pretty undefined :( Anyone shed any light on this for me? Thank you [Edited by - sipickles on July 8, 2007 11:31:06 AM]

Share this post


Link to post
Share on other sites
Advertisement
Have you seen this? Window Features

Maybe this is an issue?

Quote:

To create a layered window, specify the WS_EX_LAYERED extended window style when calling the CreateWindowEx function, or call the SetWindowLong function to set WS_EX_LAYERED after the window has been created. After the CreateWindowEx call, the layered window will not become visible until the SetLayeredWindowAttributes or UpdateLayeredWindow function has been called for this window. Note that WS_EX_LAYERED cannot be used for child windows.


Here's more from that link regarding z-order.

Quote:

When an application creates a window, the system puts it at the top of the z-order for windows of the same type. You can use the BringWindowToTop function to bring a window to the top of the z-order for windows of the same type. You can rearrange the z-order by using the SetWindowPos and DeferWindowPos functions.


Here is an account of how windows manages it's z-ordering that might be helpful

10 Things I Hate About Win32: Confusing Z ordering

Share this post


Link to post
Share on other sites
Did you try to use the HWND in the second SetWindowPos parameter?

Something like this:

SetWindowPos( bg, HWND_NOTOPMOST, x, y, w, h, 0 );
SetWindowPos( vid, bg, x, y, w, h, 0 );


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!