Archived

This topic is now archived and is closed to further replies.

Showing the children of a hidden parent

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

Im trying to make an app graphically similar to winamp (with multiple windows that dock and move together). Ive come to the conclusion that all the windows are the children of a parent that is hidden and when the user drags the main window (the player) the hidden parent is moved to match (and therefore all the children move together). Does this sound in any way correct or feasible? Ive managed to imitate this with a parent that you can see (i.e. skinned some child windows in an mdi mfc app and then moved the parent and all the children move accordingly and it looks exactly the same as winamp-obviously without the ugly grey parent window behind them). Ive also used spy++ and found that all the winamp windows have the WS_CLIPSIBLINGS style which to me suggests a common parent (and therefore one you cant see). Can anyone tell me how i can hide the parent window while still showing the child windows? or if not tell me another way of doing this? Ive tried doing it a different way in creating all the windows and then when the user drags one I manually move each window in turn. This works, however it looks a bit silly in that the windows "follow" each other rather than move as one. I also have problems doing it this way with the windows overlapping slightly (as they move)and destroying that part of the skin which needs to be repainted, but I get a flickering in that region the color of the windows background (rather than the skin if you see what I mean). Ive been trying to get this working now for a few weeks but nothin i have done has been close enough to how winamp works so any help you can give me is very much appreciated.

Share this post


Link to post
Share on other sites
Just a guess:
The parent is not hidden, it is transparent. The visibility of the children, depend on the parent, so the parent has to be visible (read transparent) for the children to show.

Share this post


Link to post
Share on other sites
Thanks for the reply, yeah ive just came to that conclusion and have been trying to find a way to make the parent window transparent.

All I can find is the style WS_EX_TRANSPARENT which (despite doing nothing when i tried to use it lol) doesnt seem to make the window transparent. It draws sibling windows created by the same thread that are underneath the window first and then it is drawn (i assume without painting over the siblings just drawn). I might be wrong but doesnt that mean only windows that are created by my app and are underneath the window show through? i.e. whatever other apps are open when its run will not show through and child windows dont count as siblings and are in front of the window anyway? Hmmm i seem to have confused myself now.

Anyone care to enlighten me on how to draw a transparent window?

cheers

Share this post


Link to post
Share on other sites
Thanks for the reply that looks like it would be useful except i need it to run on older platforms aswell as windows2000/xp (ive only got windows me at home).

After studying winamp more thoroughly im beginning to think that the approach winamp uses isnt what i thought it was, if you run an intensive app (and therefore the computer- well this computer- moves winamp slowly), i noticed while logging messages in spy++ you can see that in fact the winamp windows do move differently but arent exactly following each other, for example if you have only the player and playlist open and drag the player say to the left the playlist seems to move first.

Im pretty much at a loss as to how to make my secondary windows follow the main window without having all the flickering regions as they overlap. Surely what im trying to do isnt this complicated lol.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Some Ideas:

Create seperate windows (and threads preferably) for each of the children you want. Then merely send information to each other about their states. I.E. when the main one shuts down all the others recieve a message to do the same. Also windows can be docked fairly easily by just figuring out the distance from the side of one to the other and if it is within the acceptable threshold a simple SetWindowPos call. You can also take over the device context of the individual windows directly, doing so you can alter the way the drawing takes place - a good step toward flickerless windows.

Share this post


Link to post
Share on other sites
I''m not very experienced with Windows user interface so I''m not usre this is possible, but can''t you intervene when the user drags a window so that Windows doesn''t automaticly move it; you just get the event that the user is trying to move the window. Then you somehow get where the user tried to move the window, and then move all the windows at once.

Share this post


Link to post
Share on other sites
Thanks for the replies guys. CWizard, hehe, i cant believe i didnt think of that, ive been pithering about with WM_WINDOWPOSCHANGING all day and yet it never ocurred to me to move the windows on that rather than WM_MOVE (WM_MOVE is triggered after the window has moved whereas WM_WINDOWPOSCHANGING is triggered before it does).

And now ive got it almost perfect. I say almost because now if i move the main window in the direction of the a secondary window i get no flicker (because as i move it say to the right then any window on the right will have moved to the new position already and therefore i get no overlapping). However i still get the flickering if i move the window in the opposite direction (because if the window is on the right of the main one when i move the main window to the left then the right hand window moves first and overlaps the main window.

I guess i could sort out which way the main window is moving and if its towards a window then move that window first and if not move the main window first. Seems a bit dodgy to me though doing it that way.

Anyway thanks for the help guys but of course if anyone wants to offer more id gladly recieve it.

Cheers

Edit: this problem might be rather simple aswell. It seems that if a window is overlapped by another one it wont paint the region that is overlapped. So all I need to do is make sure all of the window is repainted or specifically that region whenever it is overlapped. The problem however is the hdc i get from beginpaint must give me only the region that isnt overlapped. Am i going in the right direction here?

Cheers

[edited by - Zeke on July 25, 2002 1:20:32 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Check out:
CRgn
SetWindowRgn

For making windows seem transparent or of different shapes.

-James

Share this post


Link to post
Share on other sites