Sign in to follow this  
Talib

win32 child windows paint problem

Recommended Posts

Hi I am making a card game (yes, yet another one). Each card is a child window. I am using the cards.dll, that's ships with windows, for my front of the card and blitting my own background. When I have multiple cards on top of each other and I move a card over this "card stack" windows needs to redraw the images when the areas are revealed again. The problem is that windows ends up redrawing the cards that are below the top card, over the top card. (Hope you understood this) I don't think this has much to do with the z-order as the top window still gets the messages sent by windows and not the bottom ones. Secondly, if a user clicks on a window and it activates, windows moves it the top of the z-order. Is there a way to prevent this? Thanks for any help.

Share this post


Link to post
Share on other sites
I did a Spy++ on Solitaire, and I it seems they're not using child windows. Wonder if they had the same problems as I did and gave up on using child windows.

Share this post


Link to post
Share on other sites
For those of you that need a visual experience:

The Cards:


Moving the Ace of hearts over the other cards:


Now after moving the Ace of hearts back, we have some weird painting issues:


Yet if you click on the affected region, the messages are sent to the Ace of Diamonds:

Share this post


Link to post
Share on other sites
You shouldn't make the cards child windows. Embedded child windows are not designed to behave well when moving around (as you've seen). The only way would be to use a MDIClient class window as the background window.

Way better, do the drawing of the cards inside WM_PAINT or WM_ERASEBKGND. It'll be faster and cleaner.

Share this post


Link to post
Share on other sites

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